【问题标题】:Pybbm superuser profile "UserProfile matching query does not exist."Pybbm 超级用户配置文件“UserProfile 匹配查询不存在。”
【发布时间】:2013-03-26 07:36:58
【问题描述】:

我在 django 1.4.5 上有一个项目,其中包含自定义用户配置文件和全新安装的 pybbm,如本说明中所述https://pybbm.readthedocs.org/en/latest/install.html#enable-your-site-profile

在本说明中: “如果您启用了南并在南控制下使用配置文件类(如'pybb.Profile'),则不会在syncdb / migrate之后创建超级用户的配置文件。它将在此用户首次登录到站点时由pybb.middleware创建。 Pybb 中间件。”

但在第一次超级用户登录时,我得到: "UserProfile 匹配查询不存在。"

这是完整的回溯http://dpaste.com/1035237/

我看
/usr/local/lib/python2.7/dist-packages/pybb/middleware.py in process_request

这里:

        if request.user.is_authenticated():
        try:
            # Here we try to load profile, but can get error
            # if user created during syncdb but profile model
            # under south control. (Like pybb.Profile).
            profile = request.user.get_profile()
        except ObjectDoesNotExist:
            # Ok, we should create new profile for this user
            # and grant permissions for add posts
            user_saved(request.user, created=True)
            profile = request.user.get_profile()

但没有为超级用户创建个人资料。

如何解决问题?

【问题讨论】:

  • 能否请您发布错误的完整回溯(哪一行产生错误)?谢谢! :)
  • 是的,这里有完整的追溯dpaste.com/1035237
  • 在我看来,中间件代码应该捕获一个 DoesNotExist 异常,而不是一个 ObjectDoesNotExist。但是,您是否以某种方式更改了配置文件类?
  • 我的个人资料继承自 pybb.models.PybbProfile pastebin.com/uAZvAbZD
  • 一切正常。我重写 pybb.signals.py pastebin.com/6UXbaJid

标签: django user-profile


【解决方案1】:

检查 'pybb.middleware.PybbMiddleware' 在您的 settings.py 中是否启用

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-12-05
    • 1970-01-01
    • 2012-11-14
    • 2021-01-25
    • 2022-01-15
    • 2022-01-08
    • 2012-06-05
    • 1970-01-01
    相关资源
    最近更新 更多