django.连接mysql报错raise ImproperlyConfigured

django连接mysql报错。

from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager

  File "/Library/Python/3.7/site-packages/django/contrib/auth/base_user.py", line 47, in

    class AbstractBaseUser(models.Model):

  File "/Library/Python/3.7/site-packages/django/db/models/base.py", line 121, in __new__

    new_class.add_to_class('_meta', Options(meta, app_label))

  File "/Library/Python/3.7/site-packages/django/db/models/base.py", line 325, in add_to_class

    value.contribute_to_class(cls, name)

  File "/Library/Python/3.7/site-packages/django/db/models/options.py", line 208, in contribute_to_class

    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())

  File "/Library/Python/3.7/site-packages/django/db/__init__.py", line 28, in __getattr__

    return getattr(connections[DEFAULT_DB_ALIAS], item)

  File "/Library/Python/3.7/site-packages/django/db/utils.py", line 207, in __getitem__

    backend = load_backend(db['ENGINE'])

  File "/Library/Python/3.7/site-packages/django/db/utils.py", line 111, in load_backend

    return import_module('%s.base' % backend_name)

  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module

    return _bootstrap._gcd_import(name[level:], package, level)

  File "/Library/Python/3.7/site-packages/django/db/backends/mysql/base.py", line 37, in

    raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)

django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.

 

把这个文件

/Library/Python/3.7/site-packages/django/db/backends/mysql/base.py

中的

if version < (1, 3, 3):
    raise ImproperlyConfigured("mysqlclient 1.3.3 or newer is required; you have %s" % Database.__version__)

这两行注释掉就好了。。。。

你可能感兴趣的:(Python)