In my mezzanine based django project I have Debug = False set within my settings.py file
However, when visiting a url that does not exist my project still throws this error:
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
Is there a second location where Debug needs to be set?
My guess is you need to change it in local_settings.py, which overrides settings.py variables in a Mezzanine project by default.
While sometimes useful, running the development server with DEBUG = False is not a use case Mezzanine is designed to support out of the box and you may encounter buggy behavior. I recommend primarily using DEBUG = True with the development server and DEBUG = False with your production server.
Related
I have a Django API that is being deployed in PythonAnywhere.
For that, I can not let the default option in settings.py as True:
DEBUG=True
However, the app also has a Swagger page using drf-yasg library. For that to work locally, I have to set the debug option as true.
However is being troublesome to maintain it, and I often mistakenly commit it as True to the repository.
Is there anyway I could manage this option so whenever I am running locally, it will automatically set it to True, but leave it as False by default?
DEBUG=False
For this purpose I use python-decouple package. To distinguish between production and development environments you can create one .env file with all production-related variables in it. In settings.py when retrieving the configuration parameters leave every default option with the one used in development. So when .env file is not present the default values are gonna be set.
from decouple import config
DEBUG = config('YOUR_ENV_VAR_DEBUG', default=True, cast=bool)
For more real-world use cases, please refer to the documentation.
I've been developing a couple of applications inside a Django CMS installation and have found it caches things well against my orders. This might not be such an issue in production but while I'm testing layouts, having to wait 10 minutes (or restart memcache) gets pretty boring.
Can I disable Django CMS's caching globally in my development settings?
Set the following settings locally:
CMS_PAGE_CACHE = False
CMS_PLACEHOLDER_CACHE = False
CMS_PLUGIN_CACHE = False
If it still caches after that, then it could be a bug..
I know this question has been discussed. But the problem persists, and I am left without any solution. Please help.
My platform is: Ubuntu 14.04 LTS, Python 3.4, MySQL 5.5, Django 1.7, Nginx 1.4.6, and Gunicorn 19.1.1.
When I set DEBUG = False in the production server, my Django application runs OK for maybe half a day. And after that, the annoying Server Error (500) always appear for certain functions, but not every one. If I turn DEBUG = True, everything will be fine.
I also set ALLOWED_HOSTS = ['*']. Some said that it should not be a wild card in production. But my app is for public, how should I set it? Others said that it should be 'localhost'. But only localhost can access the server? Why go production, then?
Is there a standard solution to this problem? Thanks.
500 error on production is not something you should make guesses about.
You need to know exactly what, where and when is it happening:
enable Django Logging and log, log, log
set ADMINS configuration setting and receive emails on critical errors
ADMINS
Default: () (Empty tuple)
A tuple that lists people who get code error notifications. When
DEBUG=False and a view raises an exception, Django will email these
people with the full exception information.
Other related materials:
Getting Started with Django Logging in 5 Minutes
"Chapter 24: Logging: What's It For, Anyway?" chapter of "Two Scoops of Django"
I understand that it doesn't provide you with an answer and doesn't directly solve your problem, but I hope you get my point, thanks.
Hello everybody and thanks in advance for the helpers!
I have created a django project and I want to run it on the server in production mode.
I have set the setting.py DEBUG = False and suddenly some of my CSS files got "missing".
Some of the pages, and those pages viewed without style but other pages where viewed properly, although all of my html pages have the same css link.
I did my research and found out that when I changed the DEBUG to False django don't handle my static files any more.
Is there any guide for noobies in the servers and web area?
Can someone tell me what am I doing wrong ?
When I make or alter translations in Rosetta in Django backend, the po and mo files get updated. However, I don't see them directly show up in the frontend.
The doc of Rosetta says:
NEW: if your webserver supports it, you can force auto-reloading of
the translated catalog whenever a change was saved. See the note
regarding the ROSETTA_WSGI_AUTO_RELOAD variable
So which conditions should the webserver fulfill for this to work?
as far as i have understood you have to set up your server with wsgi (e.g. Apache mod_wsgi) to use this feature.
ROSETTA_WSGI_AUTO_RELOAD and ROSETTA_UWSGI_AUTO_RELOAD: When running WSGI daemon mode, using mod_wsgi 2.0c5 or later, this setting controls whether the contents of the gettext catalog files should be automatically reloaded by the WSGI processes each time they are modified. For performance reasons, this setting should be disabled in production environments. Default to False.
You just need to add ROSETTA_WSGI_AUTO_RELOAD = True and ROSETTA_UWSGI_AUTO_RELOAD = True in your settings.py file.
If you have multiple settings.py file then have add these lines for all your settings file.
Example:
ROSETTA_WSGI_AUTO_RELOAD = True
ROSETTA_UWSGI_AUTO_RELOAD = True