Project Settings in Django

There are several settings that Django includes in settings.py file. Below are the few settings which are required:

  • DEBUG: DEBUG is a Boolean that turns the debug mode of the project on and off. When it is set to True, Django will display detailed error pages when an uncaught exception is thrown by the application. When you move to a production environment, remember that you have to set it to False. Never deploy a site into production with DEBUG turned on because you will expose sensitive project-related data.
  • ALLOWED_HOSTS: ALLOWED_HOSTS is not applied while debug mode is on or when the tests are run. Once you move your site into production and set DEBUG to False, you will have to add your domain/host to this setting in order to allow it to serve your Django site.
  • INSTALLED_APPS: INSTALLED_APPS is a setting you will have to edit for all projects. This setting tells Django which applications are active for this site. By default, Django includes the following applications:
    • django.contrib.admin: Is an administration site
    • django.contrib.auth: Is an authentication framework
    • django.contrib.contenttypes: Is a framework for handling content types
    • django.contrib.sessions: Is a session framework
    • django.contrib.messages: Is a messaging framework
    • django.contrib.staticfiles: Is a framework for managing static files
  • MIDDLEWARE: MIDDLEWARE is a list that contains middleware to be executed.
  • ROOT_URLCONF: ROOT_URLCONF indicates the Python module where the root URL patterns of your application are defined.
  • DATABASES: DATABASES is a dictionary that contains the settings for all the databases to be used in the project. There must always be a default database. The default configuration uses an SQLite3 database.
  • LANGUAGE_CODE: LANGUAGE_CODE defines the default language code for this Django site.
  • USE_TZ: USE_TZ tells Django to activate/deactivate timezone support. Django comes with support for timezone-aware datetime. This setting is set to True when you create a new project using the startproject management command.

Comments

Popular posts from this blog

Internationalization (Language Setting) in Django

reverse_lazy() Method in Django

CharFilter in Django