django 创建超级用户时报错 1146

前言

博主目前在使用django部署web服务,遇到了一些列问题,特此记录,方便自己和别人

目录

文章目录

  • 前言
  • 目录
  • 描述
  • 解决方法

描述

操作(创建超级用户):
python manage.py createsuperuser

报错内容:
django.db.utils.ProgrammingError: (1146, “Table ‘auth_user’ doesn’t exist”)

原因:
迁移同步时没有创建auth_user表。

解决方法

重新迁移同步,django会自动解决上述问题

python manage.py makemigrations
No changes detected
python manage.py migrate
Operations to perform:
  Apply all migrations: TestModel, admin, auth, contenttypes, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying sessions.0001_initial... OK

(exam2) D:\Anaconda\envs\exam2\Scripts\HelloWorld>python manage.py createsuperuser
用户名 (leave blank to use 'challenger'): 123

你可能感兴趣的:(Python学习笔记)