无法为'created_by'创建表单字段,因为尚未加载其相关模型'users.User'

Ben*_*shi 5 django

我最近安装了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.
Run Code Online (Sandbox Code Playgroud)

所以我添加了settings.AUTH_USER_MODEL,现在我收到以下消息:

ValueError: Cannot create form field for 'created_by' yet, because its related model 'users.User' has not been loaded yet
Run Code Online (Sandbox Code Playgroud)

我通过我调用的settings.py AUTH_USER_MODEL = 'users.User',然后将它向上移动到settings.py上以尝试更快地加载它.

按照要求: created_by = models.ForeignKey(settings.AUTH_USER_MODEL, unique=False)

我该怎么做才能解决这个问题?

Nic*_*tot 2

Blogango(是https://github.com/agiliq/django-blogango吗?)似乎不支持Django 1.5 中引入的自定义用户模型

Blogango 中的补丁应该很简单,只需替换:

from django.contrib.auth.models import User
Run Code Online (Sandbox Code Playgroud)

和:

from django.contrib.auth import get_user_model
User = get_user_model()
Run Code Online (Sandbox Code Playgroud)

django-blogango/blogango/models.py