我是Pinax和Django的新手。我試圖通過從插入的其他應用程序(在本例中,django-swingtime:http://code.google.com/p/django-swingtime/)提取OneToOneField來擴展Pinax Profile模型。我已經將所有模型顯示在django管理界面中,但我無法添加新用戶(我想在添加新配置文件的過程中執行此操作)。我收到以下錯誤:在Pinax中自定義配置文件模型:添加OnetoOneField時在管理中出現完整性錯誤
IntegrityError at /admin/auth/user/add/
profiles_profile.event_type_id may not be NULL
Request Method: POST
Request URL: http://localhost:8000/admin/auth/user/add/
Django Version: 1.3.1
Exception Type: IntegrityError
Exception Value:
profiles_profile.event_type_id may not be NULL
我的Pinax版本是0.9a2。 EventType是來自django-swingtime的模型。當我試圖從Django管理員中的任何地方添加用戶時,出現此錯誤。
這裏是我的個人資料/ models.py(改線旁邊有評論)
from django.db import models
from django.utils.translation import ugettext_lazy as _
from idios.models import ProfileBase
from swingtime.models import EventType #ADDED HERE
class Profile(ProfileBase):
name = models.CharField(_("name"), max_length=50, null=True, blank=True)
about = models.TextField(_("about"), null=True, blank=True)
location = models.CharField(_("location"), max_length=40, null=True, blank=True)
website = models.URLField(_("website"), null=True, blank=True, verify_exists=False)
event_type = models.OneToOneField(EventType) #ADDED HERE
def __unicode__(self):
return "Name: %s -- %s" % (self.name, self.about) #ADDED HERE
也許,如果有人可以解釋帳戶,配置文件,以及用戶和哪些文件確定編輯之間的關係哪些是不適合編輯的(例如,我不認爲我想在Pinax站點包中改變任何東西......),我可以取得一些進展。另外,我認爲這個idios插件參與了這個過程,但是我找到的文檔鏈接將會加載(http://oss.eldarion.com/idios/docs/0.1/)。
謝謝!