2013-08-06 22 views
5

我最近安裝Blogango,在那裏我有以下錯誤:無法爲「CREATED_BY」創建表單字段,但因爲它的相關模式「users.User」尚未加載尚未

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現在我得到以下信息:

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,試圖把它加載更快。

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

我能做些什麼來解決這個問題?

+2

我們可以看到'created_by'的模型嗎? –

+0

現在的問題顯示'created_by'。 –

+0

如果將'settings.AUTH_USER_MODEL'放在引號中會發生什麼?即'created_by = models.ForeignKey('settings.AUTH_USER_MODEL',unique = False) –

回答

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

相關問題