简体   繁体   English

Django注册:如何更改表单(需要添加有效的提交按钮!)

[英]Django-Registration: How to alter the form (need to add submit button that works!)

So I am trying to alter one of the forms from Django-registration : an app I installed via pip. 因此,我尝试更改Django注册中的一种形式:我通过pip安装的应用程序。

As stated in the docs, I was to created a registration/registration_form.html and use form as my context: 如文档所述,我要创建一个registration / registration_form.html并使用form作为上下文:

<html>
<p>This is the registration form</p>
<ul>
{{ form.as_ul}}
</ul>
</html>

So I have 2 questions: 所以我有两个问题:

1) How am I to alter the form to have a submit button that actually works in this case? 1)在这种情况下,如何更改表单以使其具有实际可用的提交按钮?

2) How can I alter the django-registration models so that I can ultimately add more to the registration forms? 2)如何更改django注册模式,以便最终可以在注册表格中添加更多内容?

Yes I looked over the docs, I am asking here because the language confused me and seemed slightly advance for me. 是的,我查看了文档,我在这里问是因为该语言使我感到困惑,并且对我来说似乎有点进步。

Thank you! 谢谢!

You need to add the form tags and a submit button. 您需要添加表单标签和提交按钮。 Something like this: 像这样:

<html>
  <p>This is the registration form</p>
  <form action="/url/to/register/" method="POST">
    {{form.as_ul}}
    <input type="submit" value="Register">
  </form>
</html>

where "/url/to/register/" will need to be pointed at your view code in your urls.py. 需要在urls.py中将“ / url / to / register /”指向您的视图代码。 Something like this: 像这样:

from django.conf.urls import url, patterns
from yoursite.registrations import views

urlpatterns = patterns('',
    url(r'^url/to/register/', views.register_some_guy),
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM