Forums

errors with debug=False

Hello,

my web app seems to be working fine with debug=True, but when set to False, I get an internal server error. I have researched this topic in depth and I'll show you the steps I've taken based on what I've read.

ALLOWED_HOSTS=['www.mydomain.com']

I collected static files and wrote them in base.py as:

STATIC_ROOT = '/home/DavidW/Blog_Portfolio_App/static' STATIC_URL = '/static/'

MEDIA_ROOT = '/home/DavidW/Blog_Portfolio_App/media' MEDIA_URL = '/media/'

I also wrote the same for the pythonanywhere web section

I have a valid SECRET_KEY in my dev.py setting, which imports base.py.

the wsgi file points to my settings file and works fine for dev.py when debug is true.

Is there anything I'm missing? Please advise. I've read the relevent documentation from pythonanywhere and collectstatic from django.

Thank you

UPDATE:

I had these activated in my production.py but was set to TRUE, then later 'true' which is incorrect.

CSRF_COOKIE_SECURE = True

SESSION_COOKIE_SECURE = True

Also, DEBUG has to be set to 'FALSE' not FALSE or 'False,' and manage.py also has to point to the same place as the wsgi file. importing from .local works best at the bottom of the file as well. If anyone else is having issues, I hope this helps.

Glad you worked it out, and thanks for posting your solution!

Woow

It worked

What worked for me was setting debug='FALSE' with inverted commas

Thanks

I know the exact solution of the media files are not loading error while setting debug to false. Sol : Be sure not to keep slash at the end of the url of media files in templates, or it will return the error.

That's it. Thank you .

None of the solutions above are the correct solution to the problem.

Just set the Debug = False

MEDIA_URL = '/media/'

MEDIA_ROOT = '/home/myusername/myproject/media'

Generally on PythonAnywhere you'd need an extra step to set up static files mappings.