> Hi, i set up static files for development purposes in following way:
>
> urls.py:
>
>
> if settings.DEBUG:
> urlpatterns += patterns('',(r'^site_media/(?P<path>.*)$',
> 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),)
>
> settings.py:
>
> MEDIA_ROOT = '/home/bagheera/NetBeansProjects/nml-src/storage'
> MEDIA_URL = 'http://localhost:8000/site_media/'
>
> index.html template:
>
> <img alt="dupa" src="{{ MEDIA_URL }}site_media/images/clock.gif"</img>
>
> WHY i had to add "site_media" string, when it IS already included in
> MEDIA_URL ?
> If i use
> <img alt="dupa" src="{{ MEDIA_URL }}images/clock.gif"</img>
> dev server gives output:
> /images/clock.gif/ HTTP/1.1" 404 2155
>
> Full path to this file is:
> '/home/bagheera/NetBeansProjects/nml-src/storage/images/clock.gif'
Probably MEDIA_URL isn't set at all in that template. If even the
"localhost:8000" isn't showing up...
I saw that problem once, too. The reason was that the template is
rendered without the proper context. You'll need to pass along a
RequestContext:
from django.template import RequestContext
def your_view(request):
...
return render_to_response(
your_template,
{'some': 'parameter'},
context_instance=RequestContext(request))
Reinout
--
Reinout van Rees - reinout@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"
--
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.
No comments:
Post a Comment