How to serve staticfiles with full URL for local development?

39 views
Skip to first unread message

lucky

unread,
May 5, 2012, 3:55:53 AM5/5/12
to Django developers
There was a snippet to display a content of response in browser during
debugging http://miniblog.glezos.com/post/3388080372/tests-browser .

"One of the first issues you might face is seeing a style-less page.
This happens becuase the test server isn’t really a web server, and
you’re probably serving static files from something relative such as '/
site_media'. The solution is simple: Run a separate Django server and
tweak your development-only static URL to something like:

STATIC_URL = 'http://localhost:8000/site_media/
"

but this doesn't works anymore, because django.contrib.staticfiles
doesn't serve static when STATIC_URL contains full URL.

I found the node at https://docs.djangoproject.com/en/dev/howto/static-files/#serving-static-files-in-development
:

"That's because this view is grossly inefficient and probably
insecure. This is only intended for local development, and should
never be used in production.

Additionally, when using staticfiles_urlpatterns your STATIC_URL
setting can't be empty or a full URL, such as http://static.example.com/."

Is there a way to omit this limitation for local development?

Karen Tracey

unread,
May 5, 2012, 7:20:51 AM5/5/12
to django-d...@googlegroups.com
Please ask questions about using Django on django-users. The topic of
this list is the development of Django itself.

Karen
Reply all
Reply to author
Forward
0 new messages