Django - Difference between django.conf.settings import options and import

What is the main difference between the following import operations in a Django application?

import settings 

and

 from django.conf import settings 
+86
python django
Jan 08 2018-12-12T00:
source share
1 answer
 import settings 

The settings module (.py) of your Django project will be imported (if you, of course, write this code from the root package of your application)

 from django.conf import settings 

The object parameter from the django.conf package (the files provided by Django) will be imported. This is important because

[..] note that your code should not be imported either from global_settings or from your own settings file. django.conf.settings abstracts the concepts of default settings and site settings; It represents one interface. It also separates code that uses settings from the location of your settings.

UPDATE: if you want to define some custom settings, see this part of the documentation

+115
Jan 08 '12 at 20:16
source share



All Articles