在/ admin / login / no中的OperationalError没有这样的表:auth_user

时间:2016-12-18 12:31:22

标签: python django python-2.7 heroku

即使多次运行syncdb并使用django 1.7.4

,我也会收到此错误

我也尝试过手动迁移已安装的应用程序,但仍无法解决问题。

环境:

Request Method: POST
Request URL: https://myapp.herokuapp.com/admin/login/?next=/admin/

Django Version: 1.7.4
Python Version: 2.7.12
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'core')
Installed Middleware:
('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')


Traceback:
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  111.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/app/.heroku/python/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  52.         response = view_func(request, *args, **kwargs)
File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/admin/sites.py" in login
  361.         return login(request, **defaults)
File "/app/.heroku/python/lib/python2.7/site-packages/django/views/decorators/debug.py" in sensitive_post_parameters_wrapper
  76.             return view(request, *args, **kwargs)
File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  105.                     response = view_func(request, *args, **kwargs)
File "/app/.heroku/python/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  52.         response = view_func(request, *args, **kwargs)
File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/auth/views.py" in login
  37.         if form.is_valid():
File "/app/.heroku/python/lib/python2.7/site-packages/django/forms/forms.py" in is_valid
  162.         return self.is_bound and not bool(self.errors)
File "/app/.heroku/python/lib/python2.7/site-packages/django/forms/forms.py" in errors
  154.             self.full_clean()
File "/app/.heroku/python/lib/python2.7/site-packages/django/forms/forms.py" in full_clean
  354.         self._clean_form()
File "/app/.heroku/python/lib/python2.7/site-packages/django/forms/forms.py" in _clean_form
  378.             cleaned_data = self.clean()
File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/auth/forms.py" in clean
  192.                                            password=password)
File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/auth/__init__.py" in authenticate
  60.             user = backend.authenticate(**credentials)
File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/auth/backends.py" in authenticate
  16.             user = UserModel._default_manager.get_by_natural_key(username)
File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/auth/models.py" in get_by_natural_key
  159.         return self.get(**{self.model.USERNAME_FIELD: username})
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/manager.py" in manager_method
  92.                 return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/query.py" in get
  351.         num = len(clone)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/query.py" in __len__
  122.         self._fetch_all()
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/query.py" in _fetch_all
  966.             self._result_cache = list(self.iterator())
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/query.py" in iterator
  265.         for row in compiler.results_iter():
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in results_iter
  700.         for rows in self.execute_sql(MULTI):
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
  786.             cursor.execute(sql, params)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
  81.             return super(CursorDebugWrapper, self).execute(sql, params)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
  65.                 return self.cursor.execute(sql, params)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/utils.py" in __exit__
  94.                 six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
  65.                 return self.cursor.execute(sql, params)
File "/app/.heroku/python/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py" in execute
  485.         return Database.Cursor.execute(self, query, params)

Exception Type: OperationalError at /admin/login/
Exception Value: no such table: auth_user

1 个答案:

答案 0 :(得分:0)

如果您只是Django的新手,我建议您使用Django1.8 +或更高版本。

  1. 首先,检查配置设置是否正确。

    $ python manage.py check

  2. 然后你应该进行迁移

    $ python manage.py makemigrations

  3. 映射数据库

    $ python manage.py migrate