Python验证错误:TypeError:__ init __()需要2个参数(给定1个)

时间:2013-06-23 09:02:50

标签: python django mongodb

我安装了所有这些

django-nonrel 
djangotoolbox
mongodb-engine
python 2.7.2.5
django 1.5.2

我成功地让我的应用程序与

一起运行
python manage.py runserver

我将应用程序配置为链接到我的index.html页面,在那里我可以看到我的标题和所有内容。该应用程序似乎没有错误,但我无法获得任何mongodb集成。


在我收到此错误之前:

   $ python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    execute_manager(settings)
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 469, in execute_manager
    utility.execute()
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 272, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 77, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/Library/Python/2.7/site-packages/django/core/management/commands/syncdb.py", line 8, in <module>
    from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
  File "/Library/Python/2.7/site-packages/django/core/management/sql.py", line 9, in <module>
    from django.db import models
  File "/Library/Python/2.7/site-packages/django/db/__init__.py", line 40, in <module>
    backend = load_backend(connection.settings_dict['ENGINE'])
  File "/Library/Python/2.7/site-packages/django/db/__init__.py", line 34, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "/Library/Python/2.7/site-packages/django/db/utils.py", line 93, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/Library/Python/2.7/site-packages/django/db/utils.py", line 27, in load_backend
    return import_module('.base', backend_name)
  File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/Users/marcochiang/Library/Python/2.7/lib/python/site-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'

直到我发现我必须改变

INSTALLED_APPS = (
...apps
)

INSTALLED_APPS = [
...apps
]

这没有任何意义。一旦我修好了,我就

$ python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    execute_manager(settings)
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 469, in execute_manager
    utility.execute()
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 272, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 77, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/Library/Python/2.7/site-packages/django/core/management/commands/syncdb.py", line 8, in <module>
    from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
  File "/Library/Python/2.7/site-packages/django/core/management/sql.py", line 9, in <module>
    from django.db import models
  File "/Library/Python/2.7/site-packages/django/db/__init__.py", line 40, in <module>
    backend = load_backend(connection.settings_dict['ENGINE'])
  File "/Library/Python/2.7/site-packages/django/db/__init__.py", line 34, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "/Library/Python/2.7/site-packages/django/db/utils.py", line 94, in __getitem__
    conn = backend.DatabaseWrapper(db, alias)
  File "/Users/marcochiang/Library/Python/2.7/lib/python/site-packages/django_mongodb_engine/base.py", line 87, in __init__
    self.ops = DatabaseOperations(self)
  File "/Users/marcochiang/Library/Python/2.7/lib/python/site-packages/djangotoolbox/db/base.py", line 28, in __init__
    super(NonrelDatabaseOperations, self).__init__()
TypeError: __init__() takes exactly 2 arguments (1 given)

我无法弄清楚在哪里可以找到问题。任何帮助将不胜感激。


来源: (settings.py)

DATABASES = {
'default': {
    'ENGINE': 'django_mongodb_engine', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
    'NAME': 'testdb',                      # Or path to database file if using sqlite3.
    'USER': '',                      # Not used with sqlite3.
    'PASSWORD': '',                  # Not used with sqlite3.
    'HOST': 'localhost',                      # Set to empty string for localhost. Not used with sqlite3.
    'PORT': '27017',                      # Set to empty string for default. Not used with sqlite3.
    'SUPPORTS_TRANSACTIONS': False,
    }
}

0 个答案:

没有答案