Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include application in django settings.py

I know two ways to add an application, but what is the best for Django 1.9? I've seen both in tutorials, and apparently is the same.

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

'myApp',]

and

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

'myApp.apps.PollsConfig',]
like image 765
Capitalize Avatar asked Dec 18 '22 19:12

Capitalize


1 Answers

Django 1.9 allows you to configure your apps using an application configuration:

To configure an application, subclass AppConfig and put the dotted path to that subclass in INSTALLED_APPS.

When INSTALLED_APPS simply contains the dotted path to an application module, Django checks for a default_app_config variable in that module.

This means that if the default_app_config in your myApp/__init__.py is already equal to myApp.apps.PollsConfig, then there is no difference between adding either myApp.apps.PollsConfig or simply myApp to the INSTALLED_APPS setting.

like image 100
Selcuk Avatar answered Dec 28 '22 08:12

Selcuk