开发者

ImportError: No module named mysql.base, in django project on Ubuntu 11.04 server

I am following the steps in the Django Book and got to the part where the authors explain hot wo set up a django project to use a database. I chose mysql.

My settings in settings.py are:

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

When trying to start the server, the following message is printed:

Validating models...

Traceback (most recent call last):
  File "/home/me/workspace/mysite/src/mysite/manage.py", line 14, in <module>
    execute_manager(settings)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 442, in execute_manager
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 379, 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 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 67, in handle
    self.run(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 78, in run
    self.inner_run(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 88, in inner_run
    self.validate(display_num_errors=True)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 243, in validate
    from django.core.management.validation import get_validation_errors
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/validation.py", line 3, in <module>
    from django.contrib.contenttypes.generic import GenericForeignKey, GenericRelation
  File "/usr/local/lib/python2.7/dist-packages/django/contrib/contenttypes/generic.py", line 7, in <module>
    from django.db import connection
  File "/usr/local/lib/python2.7/dist-packages/django/db/__init__.py", line 27, in <module>
    connection = connections[DEFAULT_DB_ALIAS]
  File "/usr/local/lib/python2.7/d开发者_运维知识库ist-packages/django/db/utils.py", line 81, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 23, 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)
ImportError: No module named mysql.base

I googled a little and found out, that this message could be printed if you use an older version of MySQLd. So I made sure I got the latest version. And tested the import in an interactive python shell. It's fine.

Any other suggestions, why this doesn't work?

I am working on a fresh installed Ubuntu 11.04 Version (Wubi in Windows 7), if that matters. =)


The correct database setting is 'django.db.backends.mysql'.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜