我最近安装了Blogango,我遇到以下错误:
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.
所以我添加了settings.AUTH_USER_MODEL,现在我收到以下消息:
ValueError: Cannot create form field for 'created_by' yet, because its related model 'users.User' has not been loaded yet
我浏览了我在其中调用AUTH_USER_MODEL = 'users.User'
的settings.py,并将其向上移动到settings.py上以尝试更快地加载它。
根据要求:
created_by = models.ForeignKey(settings.AUTH_USER_MODEL, unique=False)
我该怎么做才能解决这个问题?
答案 0 :(得分:2)
似乎Blogango(是https://github.com/agiliq/django-blogango吗?)不支持Django 1.5中引入的custom user models。
Blogango中的补丁应该非常简单,只需替换:
from django.contrib.auth.models import User
使用:
from django.contrib.auth import get_user_model
User = get_user_model()
django-blogango/blogango/models.py
中的。