0

I am new at Django, and as I'm about to finalize my project, I toggled DEBUG from True to False to see if there are any actual errors. Now the static files are giving me an error 404 which I found the reason here.

As a work around, I included this in my urls.py

urlpatterns = urlpatterns + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

I then did python manage.py collectstatic

Included this in my settings.py

STATIC_ROOT = 'static'
STATIC_URL = '/static/'

Now static files load whenever I toggle DEBUG. Am I doing this incorrectly?

Community
  • 1
  • 1
Eduard
  • 666
  • 1
  • 8
  • 25
  • what this tells us is that you are planning to use manage.py runserver (the django development server) in production. If so, you are definitely doing it wrong. – e4c5 Nov 10 '16 at 03:58
  • I see, so runserver is used for development purposes only? Are there any articles that you could refer to me for production purposes? – Eduard Nov 10 '16 at 04:01
  • Found it! https://docs.djangoproject.com/en/1.10/howto/deployment/checklist – Eduard Nov 10 '16 at 04:12
  • glad you did. Please use gunicorn+nginx or mod_wsgi + httpd or something similar – e4c5 Nov 10 '16 at 04:35

0 Answers0