python - 让 django-registration 和 django-profile 一起工作

标签 python django authentication django-registration

我正在设置一个新的 django 项目,我想使用提供的应用程序 django-registration 和 django-profile。我使用 easy-install 安装了它们,并设法使 django-registration 正常工作。我的下一步是将 django-profile 应用程序连接到工作分支。 django-registration 提供了一种服务,可以重定向到一个 URL,该 URL 在 settings.py 变量 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 中的这段

For default use, create a profile model for your site and specify the AUTH_PROFILE_MODULE setting appropriately. Then add profiles to your INSTALLED_APPS setting, create the appropriate templates and set up the URLs. For convenience in linking to profiles, your profile model should define a get_absolute_url() method which routes to the view profiles.views.profile_detail, passing the username.

所以我的问题是:

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

最佳答案

由于文档类型和缺乏模板,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

关于python - 让 django-registration 和 django-profile 一起工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7800616/

相关文章:

django - 序列化ManyToMany字段Drf干草堆

关于网站用户身份验证的 PHP 最佳实践?

Android HttpClient Cookie

python - 似乎同时安装了 NumPy 1.8.2 和 1.10.4,还有 rllab 和 OpenAI gym 之间的兼容性问题?

python - 仅阅读文档导入链接,而不阅读其中的内容

python - 在 For 循环中动态创建变量,Python

django - 使用 RadioSelect 小部件自定义 Django 表单

javascript - 将 Django 与大多数静态页面结合使用

python - 在 Django 中,登录后如何检测哪个 auth 后端对用户进行了身份验证?

python googlemaps不同位置之间所有可能的距离