gpt4 book ai didi

python - 对没有迁移的应用程序的依赖 : %s"% key[0]) in the Django

转载 作者:太空宇宙 更新时间:2023-11-03 21:11:54 25 4
gpt4 key购买 nike

我需要创建自定义用户。我正在使用带有 AbstractUser 的用户模型:

from django.contrib.auth.models import AbstractUser
from django.db import models
from django.utils.html import escape, mark_safe


class User(AbstractUser):
is_student = models.BooleanField(default=False)
is_teacher = models.BooleanField(default=False)

设置.py:

INSTALLED_APPS = [
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',

'crispy_forms',

'backend.classroom',
]

我相信问题出在下面一行:

AUTH_USER_MODEL = 'classroom.User'

错误:

File "/home/davi/.local/share/virtualenvs/django-vue-template-Wl6a6m2J/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 82, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "/home/davi/.local/share/virtualenvs/django-vue-template-Wl6a6m2J/lib/python3.6/site-packages/django/db/migrations/executor.py", line 18, in __init__
self.loader = MigrationLoader(self.connection)
File "/home/davi/.local/share/virtualenvs/django-vue-template-Wl6a6m2J/lib/python3.6/site-packages/django/db/migrations/loader.py", line 49, in __init__
self.build_graph()
File "/home/davi/.local/share/virtualenvs/django-vue-template-Wl6a6m2J/lib/python3.6/site-packages/django/db/migrations/loader.py", line 226, in build_graph
self.add_external_dependencies(key, migration)
File "/home/davi/.local/share/virtualenvs/django-vue-template-Wl6a6m2J/lib/python3.6/site-packages/django/db/migrations/loader.py", line 191, in add_external_dependencies
parent = self.check_key(parent, key[0])
File "/home/davi/.local/share/virtualenvs/django-vue-template-Wl6a6m2J/lib/python3.6/site-packages/django/db/migrations/loader.py", line 173, in check_key
raise ValueError("Dependency on app with no migrations: %s" % key[0])
ValueError: Dependency on app with no migrations: classroom

obs:应用程序类应用程序位于后端文件夹中。我也尝试了以下代码:

AUTH_USER_MODEL = 'backend.classroom.User'

最佳答案

尝试为 classroom 应用创建初始迁移,然后将其声明为 AUTH_USER_MODEL,就像现在通常依赖于 auth.User 的任何内容一样取决于classroom.User

$ python manage.py makemigrations classroom

关于python - 对没有迁移的应用程序的依赖 : %s"% key[0]) in the Django,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55009086/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com