SAnderson
SAnderson

Reputation: 41

Does it matter if you use tuple vs list in installed_apps in Django

The Django tutorial says the following, using a list in the installed_apps. But the default is a tuple, and other sources also say that Django prefers tuples rather than lists in this situation.

My question is: If I follow what the tutorial says, and use a list rather than a tuple, will this cause problems elsewhere in the setup? Or does it not really matter?

I am using virtualenv on PythonAnywhere running Django 1.8 and Python 3.4


What the tutorial says to add to mysite/settings.py:

INSTALLED_APPS = [ 
    'polls.apps.PollsConfig',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

Upvotes: 4

Views: 1005

Answers (2)

Ihor Pomaranskyy
Ihor Pomaranskyy

Reputation: 5621

Yes, there is a difference. Tuples are immutable.

Sometimes it's handy to be able to append something to initial applications list (for example, in 'local' configs, imported at the end of settings.py). If you have your INSTALLED_APPS in tuple you can only replace the whole value. If you have them in list — you can just append something.

Upvotes: 7

Daniel Roseman
Daniel Roseman

Reputation: 599846

No. Tuples and lists are exactly equivalent here.

Upvotes: 4

Related Questions