Using settings without setting DJANGO_SETTINGS_MODULE

In some cases, you might want to bypass the DJANGO_SETTINGS_MODULE environment variable. For example, if you're using the template system by itself, you likely don't want to have to set up an environment variable pointing to a settings module. In these cases, you can configure Django's settings manually. Do this by calling:

django.conf.settings.configure(default_settings, **settings) 

Example:

from django.conf import settings 
settings.configure(DEBUG=True, TEMPLATE_DEBUG=True) 

Pass configure() as many keyword arguments as you'd like, with each keyword argument representing a setting and its value. Each argument name should be all uppercase, with the same name as the settings described above. If ...

Get Mastering Django: Core now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.