5

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',]

1 Answer 1

13

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you very much !, I really thought it had a difference!
This is the best answer I found after a day. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.