django-registration简单的后端设置

时间:2012-11-18 03:19:34

标签: 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')),
    )

接下来我该怎么办? 此外,简单后端需要哪些模板,而不是默认后端?

1 个答案:

答案 0 :(得分:1)

对于模板,请在模板文件夹中创建文件夹名称“注册”。

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

  • registration/registration_form.html:注册表
  • registration/activate.html:激活页面
  • registration/activation_complete.html:激活完成
  • registration/registration_complete.html:注册完成
  • registration/registration_closed.html:disabllowed registration

对于注册表单页面,django以变量名“表单”返回表单模型。您可以在模板中调用它,如下所示:

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