Skip to content

Upgraded 1.3->1.4 and now I get this error #129

Closed
ElGoorf opened this Issue May 4, 2012 · 14 comments
@ElGoorf
ElGoorf commented May 4, 2012
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/gunicorn/arbiter.py", line 456, in spawn_worker
    worker.init_process()
  File "/usr/lib/pymodules/python2.7/gunicorn/workers/base.py", line 100, in init_process
    self.wsgi = self.app.wsgi()
  File "/usr/lib/pymodules/python2.7/gunicorn/app/base.py", line 101, in wsgi
    self.callable = self.load()
  File "/usr/lib/pymodules/python2.7/gunicorn/app/djangoapp.py", line 128, in load
    self.validate()
  File "/usr/lib/pymodules/python2.7/gunicorn/app/djangoapp.py", line 116, in validate
    if get_validation_errors(s):
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/validation.py", line 23, in get_validation_errors
    from django.db import models, connection
  File "/usr/local/lib/python2.7/dist-packages/django/db/__init__.py", line 40, in <module>
    backend = load_backend(connection.settings_dict['ENGINE'])
  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 92, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 24, in load_backend
    return import_module('.base', backend_name)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/usr/local/lib/python2.7/dist-packages/django_mongodb_engine/__init__.py", line 13, in <module>
    settings.INSTALLED_APPS.insert(0, 'django_mongodb_engine')
AttributeError: 'tuple' object has no attribute 'insert'

Not sure what to do about it (I've only been using Django a few days). I specifically tried the 1.4 fork and no luck.

@jonashaag

Woops, seems like our code doesn't handle tuple INSTALLED_APPS correctly. If INSTALLED_APPS is a tuple it should be converted to a list first.

Patches welcome.

@anemitz anemitz added a commit to anemitz/mongodb-engine that referenced this issue May 9, 2012
@anemitz anemitz fix for issue #129 where the app injecting itself into INSTALLED_APPS…
… doesn't work when defined as a tuple
5df4ad3
@anemitz anemitz added a commit to anemitz/mongodb-engine that referenced this issue May 9, 2012
@anemitz anemitz fix for #129. re-committing to develop. 77da6af
@jonashaag jonashaag closed this May 14, 2012
@yetis
yetis commented Sep 23, 2012

please pull the master

@guiyang
guiyang commented Oct 1, 2012

please pull it to the master, thanks.

@lukateake

+1 on the pull to master, please!

@bryankaplan

The fix seems to have disappeared.

@jacobcui

This issue came again.

@FMRb
FMRb commented Feb 27, 2013

Same issue, does someone know how to fix it?

@bryankaplan

FMRb: The work-around is to change your tuple to a list.

@shashank9487

a new error arrived after converting installed_apps tuple to list is:

Traceback (most recent call last):
File "manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/init.py", line 397, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/init.py", line 390, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
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
translation.activate('en-us')
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
__import
(name)
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)

@georgedorn

This is a new issue, unrelated to INSTALLED_APPS being a list or tuple.

@liuyuwan

I have this issue after I changed INSTALLED_APPS to list. How can I fix it?

@liuyuwan
@bryankaplan

@liuyuwan Sorry, I deleted my previous reply because I wrote it in haste and quickly realized it was inapplicable advice.

I'm not currently able to reproduce this. Anyone else?

@jabadabadu

I have the same problem as @liuyuwan, after upgrading from django 1.3 to django 1.4 or higher, I get an error:

Traceback (most recent call last):
File "manage.py", line 21, in
execute_manager(settings)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/init.py", line 459, in execute_manager
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/init.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/init.py", line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/init.py", line 69, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
import(name)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/test.py", line 7, in
from django.test.utils import get_runner
File "/usr/local/lib/python2.7/dist-packages/django/test/init.py", line 5, in
from django.test.client import Client, RequestFactory
File "/usr/local/lib/python2.7/dist-packages/django/test/client.py", line 21, in
from django.test import signals
File "/usr/local/lib/python2.7/dist-packages/django/test/signals.py", line 2, in
from django.db import connections
File "/usr/local/lib/python2.7/dist-packages/django/db/init.py", line 40, in
backend = load_backend(connection.settings_dict['ENGINE'])
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 93, in getitem
conn = backend.DatabaseWrapper(db, alias)
File "/usr/local/lib/python2.7/dist-packages/cassango/base.py", line 112, 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: init() takes exactly 2 arguments (1 given)

This error occurs when I want to inherit from NonrelDatabaseOperations in my DatabaseOperations class in base.py file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.