Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

tuple settings.INSTALLED_APPS doesn't have an insert attribute #150

Satchitananda opened this Issue Aug 27, 2012 · 6 comments


None yet
5 participants
from django.conf import settings
settings.INSTALLED_APPS.insert(0, 'django_mongodb_engine')

this code from django_mongodb_engine.init.py throws an AttributeError: 'tuple' object has no attribute 'insert'.

Try changing your settings.INSTALLED_APPS to a list instead of a tuple.

I'm a little confused as to why this code exists at all; perhaps it would be better to require that the user include this app in their INSTALLED_APPS instead of monkeypatching it in?

Guess so to, but why this code exist here? And does the source code still depends on patched django-nonrel?

when i change INSTALLED_APPS tuple to a list, then i got this error

Traceback (most recent call last):
File "manage.py", line 10, in
File "/usr/local/lib/python2.7/dist-packages/django/core/management/init.py", line 397, in execute_from_command_line
File "/usr/local/lib/python2.7/dist-packages/django/core/management/init.py", line 390, in execute
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 240, in run_from_argv
self.execute(_args, *_options.dict)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 278, in execute
File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/init.py", line 130, in activate
return _trans.activate(language)
File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 188, in activate
_active.value = translation(language)
File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 177, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 159, in _fetch
app = import_module(appname)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/init.py", line 6, in
from django.contrib.admin.sites import AdminSite, site
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py", line 4, in
from django.contrib.admin.forms import AdminAuthenticationForm
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/forms.py", line 6, in
from django.contrib.auth.forms import AuthenticationForm
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/forms.py", line 15, in
from django.contrib.auth.models import User
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/models.py", line 42, in
class Permission(models.Model):
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 96, in new
new_class.add_to_class('_meta', Options(meta, **kwargs))
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 264, in add_to_class
value.contribute_to_class(cls, name)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 124, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/usr/local/lib/python2.7/dist-packages/django/db/init.py", line 34, in getattr
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 193, in getitem
conn = backend.DatabaseWrapper(db, alias)
File "/usr/local/lib/python2.7/dist-packages/django_mongodb_engine/base.py", line 88, in init
self.ops = DatabaseOperations(self)
File "/usr/local/lib/python2.7/dist-packages/djangotoolbox/db/base.py", line 28, in init
super(NonrelDatabaseOperations, self).init()
TypeError: Error when calling the metaclass bases
init() takes exactly 2 arguments (1 given)

I got news from everywhere mongoDB is compatible with django < 1.3....still in old version converting tuple to list is working but above itsn't

dehiz commented Jul 29, 2013

You should try to install it like this (it works for me with django 1.4):

> pip install -r requirements.txt

with requirements.txt containing the following lines:


(Ps: at least git 1.8 must be installed on your machine ...)


I tried dehiz's suggestions, I still have the same issue.

First I got this:
settings.INSTALLED_APPS.insert(0, 'django_mongodb_engine'
AttributeError: 'tuple' object has no attribute 'insert'

then I changed { to [ in INSTALLED_APPS in settings.py
now I got this:
super(NonrelDatabaseOperations, self).init()
TypeError: init() takes exactly 2 arguments (1 given)

Please advise


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment