问题描述
我最近安装了Blogango,但出现以下错误:
I recently installed Blogango, where I had the following error:
CommandError: One or more models did not validate:
blogango.blogentry: 'created_by' defines a relation with the model 'auth.User', which has been swapped out. Update the relation to point at settings.AUTH_USER_MODEL.
所以我添加了设置。AUTH_USER_MODEL现在我收到以下消息:
So I added settings.AUTH_USER_MODEL and now I get the following message:
ValueError: Cannot create form field for 'created_by' yet, because its related model 'users.User' has not been loaded yet
我经历了我的settings.py,其中调用 AUTH_USER_MODEL ='users.User'
,然后将其移到settings.py的更高位置,以尝试尽快加载它。
I went through my settings.py where it calls AUTH_USER_MODEL = 'users.User'
, and moved it higher up on the settings.py to try and get it load sooner.
根据要求:
created_by = models.ForeignKey(settings.AUTH_USER_MODEL,unique = False)
该如何解决?
推荐答案
似乎是Blogango(是?)不支持。
It seems Blogango (is it https://github.com/agiliq/django-blogango?) does not support the custom user models introduced in Django 1.5.
Blogango中的补丁应该非常简单,只需替换即可:
The patch in Blogango should be pretty simple, just replace:
from django.contrib.auth.models import User
with:
from django.contrib.auth import get_user_model
User = get_user_model()
在 django-blogango / blogango / models.py
中。
这篇关于尚无法为“ created_by”创建表单字段,因为尚未加载其相关模型“ users.User”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!