Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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',
]
like image 645
SAnderson Avatar asked Jan 07 '23 02:01

SAnderson


2 Answers

No. Tuples and lists are exactly equivalent here.

like image 131
Daniel Roseman Avatar answered Jan 12 '23 04:01

Daniel Roseman


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.

like image 37
Igor Pomaranskiy Avatar answered Jan 12 '23 06:01

Igor Pomaranskiy