Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#29107 closed Bug (fixed)

Document that ModelForm isn't actually a subclass of Form

Reported by: Haydar Al-Rikabi Owned by: nobody
Component: Documentation Version: 2.0
Severity: Normal Keywords: ModelForm, Form, subclass
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In the Django docs, I've read the following statement:
All form classes are created as subclasses of django.forms.Form, including the ModelForm, which you encounter in Django’s admin.

I believe that the above statement is wrong because as the Django project on Github does not show that ModelForm is a subclass of django.forms.Form.

in /django/forms/models.py the class ModelForm is subclass of BaseModelForm which is also a subclass of BaseForm (located in /django/forms/forms.py).
in /django/forms/forms.py the class Form is a subclass of BaseForm.

So, as you can see, both django.forms.Form and django.forms.ModelForm are subclasses of BaseForm, but ModelForm is not a subclass of Form as the docs state.

Change History (3)

comment:1 by Tim Graham, 7 years ago

Has patch: set
Summary: ModelForm is not a subclass of FormDocument that ModelForm isn't actually a subclass of Form
Triage Stage: UnreviewedAccepted

comment:2 by GitHub <noreply@…>, 7 years ago

Resolution: fixed
Status: newclosed

In ff61a25:

Fixed #29107 -- Doc'd that ModelForm doesn't actually inherit from Form.

comment:3 by Tim Graham <timograham@…>, 7 years ago

In 29dd7dcd:

[2.0.x] Fixed #29107 -- Doc'd that ModelForm doesn't actually inherit from Form.

Backport of ff61a250815d32ff185501a5afef0245fec7d878 from master

Note: See TracTickets for help on using tickets.
Back to Top