python manage.py createsuperuser

You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run ‘python manage.py migrate’ to apply them.
Traceback (most recent call last):
File “D:\anaconda3\Lib\site-packages\django\db\backends\utils.py”, line 105, in _execute
return self.cursor.execute(sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “D:\anaconda3\Lib\site-packages\django\db\backends\sqlite3\base.py”, line 360, in execute
return super().execute(query, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sqlite3.OperationalError: no such table: auth_user

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “E:\test\manage.py”, line 22, in <module>
main()
File “E:\test\manage.py”, line 18, in main
execute_from_command_line(sys.argv)
File “D:\anaconda3\Lib\site-packages\django\core\management\__init__.py”, line 442, in execute_from_command_line
utility.execute()
File “D:\anaconda3\Lib\site-packages\django\core\management\__init__.py”, line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File “D:\anaconda3\Lib\site-packages\django\core\management\base.py”, line 416, in run_from_argv
self.execute(*args, **cmd_options)
File “D:\anaconda3\Lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py”, line 90, in execute
return super().execute(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “D:\anaconda3\Lib\site-packages\django\core\management\base.py”, line 460, in execute
output = self.handle(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “D:\anaconda3\Lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py”, line 111, in handle
default_username = get_default_username(database=database)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “D:\anaconda3\Lib\site-packages\django\contrib\auth\management\__init__.py”, line 167, in get_default_username
auth_app.User._default_manager.db_manager(database).get(
File “D:\anaconda3\Lib\site-packages\django\db\models\manager.py”, line 87, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “D:\anaconda3\Lib\site-packages\django\db\models\query.py”, line 629, in get
num = len(clone)
^^^^^^^^^^
File “D:\anaconda3\Lib\site-packages\django\db\models\query.py”, line 366, in __len__
self._fetch_all()
File “D:\anaconda3\Lib\site-packages\django\db\models\query.py”, line 1935, in _fetch_all
self._result_cache = list(self._iterable_class(self))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “D:\anaconda3\Lib\site-packages\django\db\models\query.py”, line 91, in __iter__
results = compiler.execute_sql(
^^^^^^^^^^^^^^^^^^^^^
File “D:\anaconda3\Lib\site-packages\django\db\models\sql\compiler.py”, line 1622, in execute_sql
cursor.execute(sql, params)
File “D:\anaconda3\Lib\site-packages\django\db\backends\utils.py”, line 122, in execute
return super().execute(sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “D:\anaconda3\Lib\site-packages\django\db\backends\utils.py”, line 79, in execute
return self._execute_with_wrappers(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “D:\anaconda3\Lib\site-packages\django\db\backends\utils.py”, line 92, in _execute_with_wrappers
return executor(sql, params, many, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “D:\anaconda3\Lib\site-packages\django\db\backends\utils.py”, line 100, in _execute
with self.db.wrap_database_errors:
File “D:\anaconda3\Lib\site-packages\django\db\utils.py”, line 91, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File “D:\anaconda3\Lib\site-packages\django\db\backends\utils.py”, line 105, in _execute
return self.cursor.execute(sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “D:\anaconda3\Lib\site-packages\django\db\backends\sqlite3\base.py”, line 360, in execute
return super().execute(query, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django.db.utils.OperationalError: no such table: auth_user

应用所有迁移

python manage.py migrate

这条命令会根据你 INSTALLED_APPS 中注册的应用,自动在数据库里建表,包括 auth_user、django_content_type、django_session、django_admin_log 等等。

作者 admin

百度广告效果展示