【问题标题】:Get django-registration and django-profile working together让 django-registration 和 django-profile 一起工作
【发布时间】:2011-12-09 16:19:09
【问题描述】:

我正在建立一个新的 django 项目,我想使用提供的应用程序 django-registration 和 django-profile。我用easy-install安装了它们,并设法让django-registration正常工作。我的下一步是将 django-profile 应用程序连接到工作分支。 django-registration 提供了一项服务,该服务重定向到一个 URL,该 URL 在 settings.py-variable LOGIN_REDIRECT_URL 中定义。我的猜测是,我可以简单地粘贴 django-profile 应用程序的 url 来连接两者。 (例如“/profiles/”)。 我的 settings.py-variable AUTH_PROFILE_MODULE 设置在“registration.User”上(尝试使用 django-registration 模型!)。 但我得到一个 SiteProfileNotAvailable 在 /profiles/ 未提供异常 错误。 我尝试按照以下步骤操作: https://bitbucket.org/ubernostrum/django-registration/src/tip/docs/index.rst https://bitbucket.org/ubernostrum/django-profiles/src/tip/docs/overview.txt 但我不确定,如果我做的一切都正确,即来自overview.txt的这段

对于默认使用,为您的站点创建一个配置文件模型并指定 AUTH_PROFILE_MODULE 设置得当。然后添加profiles 到您的INSTALLED_APPS 设置,创建适当的模板 并设置 URL。为了方便链接到个人资料,您的 profile 模型应该定义一个get_absolute_url() 方法 通往视图profiles.views.profile_detail 的路线,通过 用户名。

所以我的问题是:

  • 这是一个众所周知的错误吗?
  • 将“registration.User”设置为 AUTH_PROFILE_MODULE 是否正确?
  • 什么是“应该定义一个get_absolute_url()方法 通往视图profiles.views.profile_detail 的路线,通过 用户名。”在 overview.txt 中?

【问题讨论】:

    标签: python django authentication django-registration


    【解决方案1】:

    由于文档类型和缺少模板,django-registration 很难使用。许多 Django 开发人员现在使用 django-social-auth 代替:

    https://github.com/omab/django-social-auth http://django-social-auth.readthedocs.org/en/latest/index.html

    您可以在此处查看 Kenneth Love 如何将其集成到 Django Packages 代码库中:

    https://github.com/opencomparison/opencomparison/blob/master/apps/profiles/views.py#L83 https://github.com/opencomparison/opencomparison/blob/master/settings.py#L277

    【讨论】:

      猜你喜欢
      • 2011-11-03
      • 2011-09-19
      • 2011-12-15
      • 1970-01-01
      • 2010-12-05
      • 1970-01-01
      • 2011-09-01
      • 1970-01-01
      • 2017-06-11
      相关资源
      最近更新 更多