4

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',
]
JDurstberger
  • 4,127
  • 8
  • 31
  • 68
SAnderson
  • 41
  • 2
  • Can you point to these "other sources"? – Daniel Roseman Dec 03 '15 at 11:03
  • 3
    Django has long been inconsistent, but in 1.9 switched all the default settings to use a list rather than a tuple. – knbk Dec 03 '15 at 11:57
  • This StackOverflow answer for example: http://stackoverflow.com/questions/12349784/why-does-django-use-tuples-for-settings-and-not-lists. But I see that it is 3 years old so I am guessing from your answer that it's outdated. – SAnderson Dec 03 '15 at 12:45

2 Answers2

6

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.

Ihor Pomaranskyy
  • 5,437
  • 34
  • 37
5

No. Tuples and lists are exactly equivalent here.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895