[Answer]-ModelForm has no model class specified Django

1👍

I’m still not quite sure how the model = User plays a roll in my
custom user registration form.

Your form inherit from django.contrib.auth.forms.UserCreationForm which is a ModelForm.

I was wondering if someone could briefly explain to me this whole
process and why model = User is needed

ModelForms are documented here : https://docs.djangoproject.com/en/1.5/topics/forms/modelforms/

As a side note, if you had inherited your form’s Meta from UserCreationForm.Meta you wouldn’t need to specify the model once again.

My guess is that model is now a User object.

User is a class.

Also args[‘form’] = MyRegistrationForm() needs to be a model object
or else the code will crash. This is as far as my assumptions go.

Don’t assume: read the doc, then read the code (remember, it’s open source software).

Leave a comment