0

我正在使用 django-registration 和 django-profiles 并在确认注册后,当我尝试访问该页面时遇到 404 http://example.com/profiles/fox/-

我在 debug_toolbar 中看到了所有已进行的查询,并在我在设置中定义的表上看到了一个AUTH_PROFILE_MODULE = 'tglr.UserProfile'- 此模型上的查询返回......什么也没有。

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

我想念什么?

感谢您的帮助

问候

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

4

1 回答 1

0

这听起来像在您注册用户时没有创建 UserProfile 记录。 Django 手册中有关用户配置文件的页面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)
于 2012-09-05T18:41:28.907 回答