Tuesday, January 25, 2011

Confusion about the new staticfiles contrib app

Hi -
I'm trying to cut over my project to use the new staticfiles
application. I'm using the dev server with DEBUG = True on a recent
SVN trunk checkout. My STATIC_URL is '/static/' and my MEDIA_URL is
'http://localhost:8000/media/' in this environment.

My first confusion point:
Maybe it was just me, but I got confused about serving my media
(MEDIA_ROOT/MEDIA_URL) files with the dev server. After cutting over
to staticfiles, my MEDIA_URL files started getting 404s. Eventually I
came to the conclusion that I had do this:

urls.py:
if settings.DEBUG:
urlpatterns += patterns('django.contrib.staticfiles.views',
(r'^media/(?P<path>.*)$', 'serve', {'document_root':
settings.MEDIA_ROOT}),
)

The docs don't seem to mention using this view for this purpose.
Should they?

My second confusion point:
I am running the dev server with -Wall and I am seeing warnings:
PendingDeprecationWarning: The view at `django.views.static.serve` is
deprecated; use the path `django.contrib.staticfiles.views.serve`
instead.

I don't understand why I'm getting these warnings. My code no longer
references django.views.static.serve. I even see this warning when
looking at an admin page. Any thoughts on why this is occurring?

Thanks.

PS After coming to terms with staticfiles, I think it is a great idea.
I like being able to separate my apps' static files from user uploaded
media files.

--
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


Real Estate