更新时间:2022-02-02 21:42:02
按照@Mohit Harshan提到的@Mohit Harshan将此行代码添加到您的应用程序的__init__.py
文件中
default_app_config = 'my_app.apps.MyAppConfig'
为什么RelatedObjectDoesNotExist
错误?
您某些User
对象没有活动与Profile
实例的关系。因此,请在Django shell中运行以下代码
users_without_profile = User.objects.filter(profile__isnull=True)
for user in users_without_profile:
Profile.objects.create(user=user)