python - django-registration 简单的后端设置

标签 python django django-registration

我正在尝试使用 simple backend 将 django-registration 添加到 django 文档中的教程应用程序中.

到目前为止,我包含了 URLconf registration.backends.simple.urls,如下所示:

from django.conf.urls import patterns, include, url

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    url(r'^polls/',     include('polls.urls')),
    url(r'^admin/',     include(admin.site.urls)),
    url(r'^accounts/',  include('registration.backends.simple.urls')),
    )

接下来我该做什么? 另外,与默认后端相比,简单后端需要哪些模板?

最佳答案

对于模板,请在模板文件夹中创建一个名为“registration”的文件夹。

然后为每个注册操作创建一个文件:

  • registration/registration_form.html:注册表单
  • registration/activate.html:激活页面
  • registration/activation_complete.html:激活完成
  • registration/registration_complete.html:注册完成
  • registration/registration_close.html:禁止注册

对于注册表单页面,django 在变量名的“form”中返回表单模型。您可以在模板中这样调用它:

<form action="/accounts/register/" method="post">
  {% csrf_token %}
  {{ form.as_p }}
  <input type="submit" value="Submit" />
</form>

关于python - django-registration 简单的后端设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13437150/

相关文章:

django - 一条特定路由的 uwsgi 段错误

python - Django 和 eBay 风格的多列表

django - 注册时如何设置多种用户类型?

python - 反转 'index',参数 '()' 和关键字参数 '{}' 未找到。 0 种模式已尝试 : []

python - 使用 cv2 findContours,图像的轮廓显得非常草率。如何提高?

python - 如何使用 dbus 为函数编写单元测试以从 Spotify 获取信息?

python - Django 问题 : Django ManagementForm data is missing or has been tampered with

django - 在 django-registration 中使用电子邮件作为用户名

python - 有没有办法将列 reshape 为行,但行是由 ID 列组成的

python - 如何解决使用 toc 将 Jupyter Notebook 下载为 HTML 的错误?