Report this

What is the reason for this report?

My Django/Python app is working only when I say Debug = True and that too static files are not loading

Posted on October 28, 2014

I am using ubuntu os and when I deployed my Django/Python app, it works only when I mention Debug=True. Apart from that when I start the server and navigate to browser I see that its not loading the static folder -any ideas?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

When you set Debug=False you need to make sure that you’ve also set your domain and/or external IP address in ALLOWED_HOSTS. See the Django documentation:

When DEBUG is True or when running tests, host validation is disabled; any host will be accepted. Thus it’s usually only necessary to set it in production.

Hi,

You need to post more info: did you run ./manage.py collectstatic? What is in your settings.py, especially the STATIC_FILES setting? How are u using the image reference in your template? Are you using {% load staticfiles %} and then use {% static ‘myimgpath’ %}? Are your static files supposed to be hosted on the same instance your app is running?

fixed it, this is because of the conflict between STATIC_ROOT = /static/ in settings.py and configuration in /etc/nginx/sites-enabled/django file, remove this part and do not forget to restart the service with service nginx restart location /media { alias /home/django/supchang/media; } location /static { alias /home/django/ssupchang/static; }

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.