Skip to content

Instantly share code, notes, and snippets.

@phpdude
Created April 13, 2015 01:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phpdude/cf931d476248bdbc646e to your computer and use it in GitHub Desktop.
Save phpdude/cf931d476248bdbc646e to your computer and use it in GitHub Desktop.
Lifehack! Nginx proxy django static files with DEBUG=True.
location /static {
root /path/to/project/;
try_files $uri @django;
}
@phpdude
Copy link
Author

phpdude commented Apr 13, 2015

Sometimes you need to proxy your django dev server with nginx without disabling DEBUG.

You can collectstatic everytime you change it, but not me :-)

This configuration tries collected static files folder first and fetch it via your django dev server if nothing found in collected.

ps: @django is your named nginx location for proxing django requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment