Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In production you shouldn't serve static files with Django. See the warning boxes on this page: <a href="https://docs.djangoproject.com/en/1.4/ref/contrib/staticfiles/#static-file-development-view" rel="nofollow">https://docs.djangoproject.com/en/1.4/ref/contrib/staticfiles/#static-file-development-view</a></p> <p>In development, Django's <code>contrib.staticfiles</code> app automatically serves staticfiles for you by overwriting the <code>runserver</code> command. This way you can't control the way it serves the static files.</p> <p>You can prevent the staticfiles app from serving the static files by adding the <code>--nostatic</code> option to the runserver command:</p> <pre><code>./manage.py runserver --nostatic </code></pre> <p>Then you can write an url config to manually serve the static files with headers you want:</p> <pre><code>from functools import wraps from django.conf import settings from django.contrib.staticfiles.views import serve as serve_static from django.conf.urls import patterns, url urlpatterns = patterns('', ) if settings.DEBUG: def custom_headers(view_func): @wraps(view_func) def wrapper(request, *args, **kwargs): response = view_func(request, *args, **kwargs) response['Custom-header'] = 'Awesome' response['Another-header'] = 'Bad ass' return response return wrapper urlpatterns += patterns('', url(r'^static/(?P&lt;path&gt;.*)$', custom_headers(serve_static)), ) </code></pre> <p>If you want your <code>manage.py</code> to have the <code>--nostatic</code> option on by default, you can put this in your <code>manage.py</code>:</p> <pre><code>if '--nostatic' not in sys.argv: sys.argv.append('--nostatic') </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload