Django 1.5: UserCreationForm & Custom Auth Model

django, django-forms, django-models, python-3.x

Solution

You need to create your form from sctratch, it should not extend the UserCreationForm. The UserCreationForm have a username field explicitly defined in it as well as some other fields. You can look at it here.

Problem

I'm using Django 1.5 & Python 3.2.3. I've got a custom Auth setup, which uses an email address instead of a username. There's no username defined in the model at all. That works fine. Yet, when I build a user creation form, it adds in a username field anyway. So I tried defining exactly which fields I want displayed, but it's still forcing a username field into the form anyway.... even tho it doesn't even exist in the custom auth model. How can I make it stop doing that? My form for this is defined like so: ``` class UserCreateForm(UserCreationForm): class Meta: model = MyUsr fields = ('email','fname','surname','password1','password2', 'activation_code','is_active') ``` At the docs, the Custom Users and Builtin Forms says it "Must be re-written for any custom user model." and I think that's what I'm doing here. Neither this, nor the UserCreationForm documentation say anything more about this though. So I don't know what I'm missing. I didn't find anything via Google either.

Original source