开发者

Creating form from Django user model

I am trying to build a form for registering a user - using Django's built in user model and using generic views. I can't figure out how to confirm a password.

<form action="."  method="post">
{% csrf_to开发者_如何学运维ken  %}
{{ form.non_field_errors }}
    <p>
        {{ form.username.errors }}
        <label for="username">Username</label>
        {{ form.username }}
    </p>
    <p>
        {{ form.email.errors }}
        <label for="email">Email</label>
        {{ form.email }}
    </p>
    <p>
        {{ form.password.errors }}
        {{ form.password.label_tag }}
        {{ form.password }}
    </p>
<p><input type="submit" value="Submit" /></p>
</form>

So my problems are that it doesn't submit and I can't confirm the password. The password is also plain text instead of hidden but I'll fix that later.

I tried form.password_confirmation and form.confirm_password but they don't work. Can't find this documented anywhere.


Give a try to django-registration to register users. It is a very complete, reusable app for that purpose. I use it and I'm quite happy with it.

http://bitbucket.org/ubernostrum/django-registration

You have the full sources to check how it solves the password confirmation issue, etc.

This may not directly answer your question, but it will probably solve your registration needs and allow you to focus your coding energies elsewhere.


I guess you mean this form: http://code.djangoproject.com/browser/django/tags/releases/1.2.3/django/contrib/auth/forms.py#L10 - in which case you should have two password fields: password1 and password2 (so it's strange that password works for you and produces plain text field...). But, as Carles Barrobés suggested, you better give a try to django-registration.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜