Re: Getting images to appear in html using Django.
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 <jacob.wisch...@gmail.com> 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 django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home