Problem with debug = True/False

320 views
Skip to first unread message

Gerald Brown

unread,
May 11, 2018, 1:09:03 AM5/11/18
to Django users
On my admin site if I have Debug set to true (I have read that for production this is a no-no) everything looks fine.  When I change it to FALSE all of the styling goes away as if it is being run using gunicorn.

Has anyone observed this?  If so have you found a correction?

Thanks.

Andréas Kühne

unread,
May 11, 2018, 5:54:37 AM5/11/18
to django...@googlegroups.com
Hi,

That is the way it should be if you look in the documentation:

Serving the files

In addition to these configuration steps, you’ll also need to actually serve the static files.

During development, if you use django.contrib.staticfiles, this will be done automatically by runserver when DEBUG is set to True (see django.contrib.staticfiles.views.serve()).

This method is grossly inefficient and probably insecure, so it is unsuitable for production.

See Deploying static files for proper strategies to serve static files in production environments.


So it is exactly like gunicorn - because you need to serve your static files from a webbserver instead of from django itself.

That's why it is failing.

What you could do (although I don't recommend it) - it to manually add the static files serving to your urls.py file. See:

This should be fine for a developer environment - but nothing else.

Regards,

Andréas

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2fb3aff8-40ec-464e-81e1-766cf08db433%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

James Farris

unread,
May 11, 2018, 1:07:39 PM5/11/18
to django...@googlegroups.com
I also recommend going through the deploy checklist. I ran into the same problem and then other problems after that because I didn’t follow this. 

To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Gerald Brown

unread,
May 11, 2018, 1:14:05 PM5/11/18
to django...@googlegroups.com

Thanks for the info. I will check it out.  I am still in development so it will be awhile before I need it.

To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Gerald Brown

unread,
May 11, 2018, 1:14:33 PM5/11/18
to django...@googlegroups.com

Thanks for the info. I will check it out.  I am still in development so it will be awhile before I need it.


Gerald Brown

unread,
May 18, 2018, 12:34:20 PM5/18/18
to Django users
My site now looks the same in Development and Production.  I think why this is happening is that I ran ./manage.py collectstatic awhile ago,  So if you are getting weird formatting when DEBUG = False try running ./manage.py collectstatic and see if that solves your problem!!!
Reply all
Reply to author
Forward
0 new messages