I figured it out. I put the Media folder on the same level as a the
mysite folder and now it seems to work. I think it was a django noob
error.
MEDIA_ROOT ='/Users/Jak/projects/fap/media/'
MEDIA_URL = '/media/'
TEMPLATE_DIRS = (
'/Users/Jak/projects/fap/mysite/templates',
urls.py
(r'^media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
HTML
<img src="{{ MEDIA_URL }}FAPLogo.jpg"/>
Thanks!
On Jul 9, 7:50 am, Rohan <[email protected]> wrote:
> Hi Jak,
> I would suggest removing the "," after MEDIA_ROOT in your settings file
> if it indeed is there. Could you also be a little more specific about
> the problem. Is the rest of the page loading fine? and if it is, do you
> see /media/ being pre-pended to your file name when you see the source
> of your html page? Are you getting a page not found error when you're
> trying to access the image directly ( <website>/media/FAPLogo.jpg) ?
>
> Additionally, are you by chance pointing ADMIN_MEDIA_PREFIX in your
> settings.py to /media/ as well?
>
> On 7/8/2012 6:30 PM, Jak wrote:
>
>
>
>
>
>
>
> > Update:
>
> > I'm now using requestcontext in my view.
>
> > my new view is
> > from django.http import HttpResponse
> > from django.shortcuts import render_to_response
> > from django.template.loader import get_template
> > from django.template import RequestContext
>
> > def homepage(request):
> > return render_to_response ('index.html',
>
> > context_instance=RequestContext(request))
>
> > But it's still not working.
>
> > Thanks again!
>
> > On Jul 8, 5:26 pm, Jak <[email protected]> wrote:
> >> Hello All,
>
> >> I am new to Django and I'm trying to create a simple website. I am
> >> trying to get an jpg to appear in the base template but I cant get it
> >> to show up.
>
> >> In setting.py
> >> MEDIA_ROOT = '/Users/Jak/projects/fap/mysite/media',
> >> MEDIA_URL = '/media/'
>
> >> urls.py
> >> (r'^media/(?P<path>.*)$', 'django.views.static.serve',
> >> {'document_root': settings.MEDIA_ROOT}),
>
> >> HTML
> >> <h1><img src="{{ MEDIA_URL }}FAPLogo.jpg"></h1>
>
> >> views.py
> >> from django.http import HttpResponse
> >> from django.shortcuts import render_to_response
> >> from django.template.loader import get_template
>
> >> def homepage(request):
> >> return render_to_response ('index.html')
>
> >> any ideas on what the problem could be? I dont get an error when I run
> >> the server.
>
> >> Thanks
>
> >> Jak
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.