How to show the email field in a UserCreationForm?

658 views
Skip to first unread message

Berco Beute

unread,
Aug 11, 2009, 12:32:13 PM8/11/09
to Django users
Hi,

I'm using the UserCreationForm for creating users, but I would like to
show the email, firstname and lastname fields as well (and they should
be required). Much like the view you get when adding a user through
the admin interface. What's the best way to do this? Extend
UserCreationForm? Or create my own forms from scratch?

2B

Berco Beute

unread,
Aug 11, 2009, 12:48:12 PM8/11/09
to Django users
To reply to my own question...I've extended UserCreationForm as
follows:

==================
class UserCreationFormExtended(UserCreationForm):

def __init__(self, *args, **kwargs):
super(UserCreationFormExtended, self).__init__(*args,
**kwargs)
self.fields['first_name'].required = True
self.fields['last_name'].required = True

class Meta:
model = User
fields = ('username', 'email', 'first_name', 'last_name')
==================
Reply all
Reply to author
Forward
0 new messages