2016-12-01 53 views
1

创建用户我有Django的1.10与MySQL,每次我输入admin时间,我尽量让用户我得到这个错误:Django的:OperationalError当我尝试从管理

enter image description here

的东西是我可以创建任何其他模型,如果我从命令行创建超级用户,我可以编辑该用户,但是当我按下“添加用户”时,出现此错误。我试着删除数据库并重新做两次。

这里是我的settings.py:

import os 

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 

DEBUG = True 

ALLOWED_HOSTS = [] 

INSTALLED_APPS = [ 
    # django apps 
    'django.contrib.admin', 
    'django.contrib.auth', 
    'django.contrib.contenttypes', 
    'django.contrib.sessions', 
    'django.contrib.messages', 
    'django.contrib.staticfiles', 

    # our apps 
    'authentication', 
    'homepages', 
    'school' 
] 

MIDDLEWARE_CLASSES = [ 
    'django.middleware.security.SecurityMiddleware', 
    'django.contrib.sessions.middleware.SessionMiddleware', 
    'django.middleware.common.CommonMiddleware', 
    'django.middleware.csrf.CsrfViewMiddleware', 
    'django.contrib.auth.middleware.AuthenticationMiddleware', 
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 
    'django.contrib.messages.middleware.MessageMiddleware', 
    'django.middleware.clickjacking.XFrameOptionsMiddleware', 
] 

ROOT_URLCONF = 'config.urls' 

TEMPLATES = [ 
    { 
     'BACKEND': 'django.template.backends.django.DjangoTemplates', 
     'DIRS': [ 
      BASE_DIR + '/templates/' 
     ], 
     'APP_DIRS': True, 
     'OPTIONS': { 
      'debug': DEBUG, 
      'context_processors': [ 
       'django.template.context_processors.debug', 
       'django.template.context_processors.request', 
       'django.contrib.auth.context_processors.auth', 
       'django.contrib.messages.context_processors.messages', 
      ], 
     }, 
    }, 
] 

WSGI_APPLICATION = 'config.wsgi.application' 

DATABASES = { 
    'default': { 
     'ENGINE': 'django.db.backends.mysql', 
     'NAME': 'isj', 
     'USER': 'test_user', 
     'PASSWORD': 'password', 
     'HOST': '', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP. 
     'PORT': '', # Set to empty string for default. 
    } 
} 

AUTH_PASSWORD_VALIDATORS = [ 
    { 
     'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 
    }, 
    { 
     'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 
    }, 
    { 
     'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 
    }, 
    { 
     'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 
    }, 
] 

LANGUAGE_CODE = 'en-us' 

TIME_ZONE = 'UTC' 

USE_I18N = True 

USE_L10N = True 

USE_TZ = True 

STATIC_URL = '/static/' 
STATICFILES_DIRS = (os.path.join('static'),) 
+1

你能否用你的settings.py来更新你的问题? –

+0

你有它:) –

+0

行“异常值”说:“SAVEPOINT ...不存在”。这个问题可能是相关的:http://stackoverflow.com/q/13728843/293494 – mkj

回答

0

就我而言,我发现,根本原因是MySQL-Python数据库驱动程序和解决方法是使用其他MySQL驱动的Python(如mysqlclient)。

$ pip uninstall MySQL-Python 
$ pip install mysqlclient 

MySQL-python原来是很老的(最后一次提交的是7年前)。 mysqlclient是它的现代版本,有很多改进和错误修复。

有关我的修复和发现here的更多详细信息。