movie rental

django newforms, passwordfield

Filed under: Blogroll — Wrote by Otu on Saturday, July 21st, 2007 @ 7:10 am

From Django 0.96, the forms have been rewritten - currently called newforms and imported as


from django import newforms as forms

newforms is a great deal better than the oldforms with all the ‘manipulation’ and a million other unholy things in it.

The problem right now however is that there is very little documentation on using the newforms library - what exists just covers the basic and as such people are having to resort to reading the code or unittests to find out how to do things.

I ‘v just spent almost an hour trying to create a password field which should logically be an extension of newforms.CharField before I found a solution. In the newforms.widgets module.

This is in case I ever forget before the full documentation comes out or in case anyone else needs to do something similar:

from django.newforms import widgets
# Forms
class RegisterForm(forms.Form):
    email = forms.EmailField()
    phnumber = forms.CharField(label='Phone Number')
    passwd1 = forms.CharField(label='Password', \
                            widget=widgets.PasswordInput())
    passwd2 = forms.CharField(label='Password Again', \
                            widget=widgets.PasswordInput())
# end RegisterForm
  -

No comments yet. Be the first to comment this post.

Leave your comment

You must be logged in to post a comment.

Formation SAGE © il maestro ignoto