Django注册 - 不完整的东西

时间:2012-09-05 13:53:58

标签: django django-registration django-profiles

我正在使用django-registration和django-profiles,在确认注册后,当我尝试访问该页面时遇到404 { - 1}} -

我在debug_toolbar中看到了所有已经创建的查询,并在我在设置http://example.com/profiles/fox/中定义的表上看到了一个查询 - 此模型上的查询返回...没有。

看起来注册确认没有完成其工作。

我错过了什么?

谢谢你的帮助

问候

编辑:如果我在UserProfile表中添加缺失记录一切顺利 - 这似乎确实证实了我遇到的行为。

1 个答案:

答案 0 :(得分:0)

这听起来像注册用户时未创建UserProfile记录。 Django手册中的The page on user profiles详细说明了post_save信号在创建用户时如何自动插入UserProfile记录。具体来说,尝试在您的用户模型附近添加此项:

# FROM THE ABOVE LINK: 
# in models.py
from django.db.models.signals import post_save

def create_user_profile(sender, instance, created, **kwargs):
    if created:
        UserProfile.objects.create(user=instance)

post_save.connect(create_user_profile, sender=User)