[Django]-Configuring Django runserver to serve static files in a non-app directory?

5👍

Move the files that are in /static/ right now to a different directory — call it /project-static/, for instance.

Then only include this line in urls.py:

urlpatterns += staticfiles_urlpatterns()

(remove the django.views.static.serve view)

And in settings.py, use this:

STATICFILES_DIRS = (os.path.join(PROJECT_ROOT, 'project-static'),)

Then you can put files in /project-static/ directory on your filesystem, the development server will serve them out of the /static/ URL prefix, and in production, collectstatic will find them and put them into the /static/ directory where the web server can find them.

Leave a comment