Question Details

No question body available.

Tags

python django

Answers (1)

Accepted Answer Available
Accepted Answer
March 30, 2025 Score: 3 Rep: 482,088 Quality: Expert Completeness: 80%

The culprit is a typo: fromclass to formclass:

from django.urls import reverselazy
from django.views.generic import CreateView

from .forms import CustomUserCreationForm

class SignUpView(CreateView): formclass = CustomUserCreationForm successurl = reverselazy('login') templatename = 'registration/signup.html'

But I think it is interesting to know why this then raises this error: if you don't provide a .formclass [Django-doc] to a CreateView, a CreateView will try to make its own form, for that it can work with the modelformfactory(…) [Django-doc], but for that it needs to know the model.

It tries to determine the model in three possible ways: first by looking if the view has a .model attribute, if not if it has an .object attribute (for an UpdateView the form can be implied by the object to update), and finally it runs the .get_queryset() method [Django-doc] to obtain the model of the QuerySet, and since none of these work with this SignUpView, we thus get that error.