Community,
I am using Django 1.7. Due to specific nature of the project, I have complicated needs for handling static files. In other words, I need /static/
to be served on development just as usual, but /static/blueprints/
subdirectory should be served by a custom view.
It seems anyway that static serving view has priority above everything in urls.py
. The following just does not work:
urlpatterns = patterns('',
url(r'^static/blueprints/(?P<blueprint>[\w-]+)/(?P<path>.+)', 'my_view_name'),
...
)
The view never gets fired when accessing an appropriate URL. But changing static/blueprints
to, say, my_static/blueprints
makes this path to work, so the view actually does work.
Of course, I need that only on development; on production, a script will be used to form the necessary directory structure served by Nginx. So solutions:
- Avoid using
debug=True
on devserver. But Django's debugger is very useful. - Avoid using
django.contrib.staticfiles
. Not pleasing too, I'd like to use thecollectstaic
command. - Use just
/blueprints/
path instead of/static/blueprints/
, which is a solution, but just against aesthetics.
Is there any more elegant solution?