Opened 8 years ago

Closed 4 years ago

Last modified 4 years ago

#10239 closed New feature (fixed)

Document modelform_factory

Reported by: ingenieroariel Owned by: Tim Graham
Component: Documentation Version: master
Severity: Normal Keywords: dceu2011
Cc: mbencun@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Attachments (2)

ticket10239.patch (2.9 KB) - added by Will Hardy 6 years ago.
Added documentation for modelform_factory
10239.diff (7.3 KB) - added by Tim Graham 4 years ago.

Download all attachments as: .zip

Change History (15)

comment:1 Changed 8 years ago by Jacob

Triage Stage: UnreviewedAccepted

I think modelform_factory is considered internal -- it's used by modelformset_factory -- and thus shouldn't be documented along with the public code. Nevertheless, in an idea world everything ought to be documented somewhere!

comment:2 Changed 6 years ago by fas

Cc: mbencun@… added

I didn't know it is considered internal, I use it very often. The formfield_callback to modify the form fields that are created for the corresponding db fields is in many cases much more useful/easier than defining the form field anew and pass all parameters explicitly (rather than having them being drawn from the model). The documentation also points out this shortcoming (Note box at http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#overriding-the-default-field-types-or-widgets.

Any chance of making this method public?

comment:3 Changed 6 years ago by Chris Beaven

Severity: Normal
Summary: Document modelform_factoryDocument modelform_factory
Triage Stage: AcceptedDesign decision needed
Type: New feature

I'm going to push this back to a design decision and mark it as a feature (the feature being the addition of this method to the documented public forms API).

Bring a discussion to the django-dev group.

comment:4 Changed 6 years ago by Will Hardy

Easy pickings: unset
Owner: changed from nobody to Will Hardy
Status: newassigned
UI/UX: unset

Changed 6 years ago by Will Hardy

Attachment: ticket10239.patch added

Added documentation for modelform_factory

comment:5 Changed 6 years ago by Will Hardy

Has patch: set
Keywords: dceu2011 added
Owner: changed from Will Hardy to nobody
Status: assignednew

comment:6 Changed 6 years ago by Peter van Kampen

Thank you. This looks good. Would it make sense to include the function's signature in modelforms.txt?

comment:7 Changed 5 years ago by Gabriel Hurley

Patch needs improvement: set
Triage Stage: Design decision neededAccepted

While I can understand that this method may have been originally considered internal, I don't see any significant reason why it is more internal than modelformset_factory, which is documented. Additionally, I've certainly seen it in use by the community in numerous places. Changing it substantially in a backwards-incompatible way without documentation would be detrimental at this stage.

As for this patch, there's a significant typo on line 540: "modelformset_factory" should be "modelform_factory".

However, what really bothers is that the only documentation for ModelForm and modelformset_factory right now is in the topic guide. There direly needs to be a API reference for these in addition to just adding another section to the topic guide.

If this patch expands to include a reference doc (new) as well as the existing improvements then I'd be willing to commit it.

comment:8 Changed 4 years ago by Tim Graham

Owner: changed from nobody to Tim Graham

I'll add some reference docs to this.

Changed 4 years ago by Tim Graham

Attachment: 10239.diff added

comment:9 Changed 4 years ago by Tim Graham

Patch needs improvement: unset

Added an expanded patch with reference docs for modelform_factory and modelformset_factory.

comment:10 Changed 4 years ago by Nick Sandford

Triage Stage: AcceptedReady for checkin

The patch misses a newline after .. note:: on line 173. Other than that it looks good.

comment:11 Changed 4 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In 71d76ec011b393990ba9f5fb63727dbe36c3c440:

Fixed #10239 - Added docs for modelform_factory

Thanks ingenieroariel for the suggestion and slurms for the review.

comment:12 Changed 4 years ago by Tim Graham <timograham@…>

In c94fcc4117987c4ebe29ad63da01035230c8afd5:

[1.5.x] Fixed #10239 - Added docs for modelform_factory

Thanks ingenieroariel for the suggestion and slurms for the review.

Backport of 71d76ec011 from master

comment:13 Changed 4 years ago by Tim Graham <timograham@…>

In c94fcc4117987c4ebe29ad63da01035230c8afd5:

[1.5.x] Fixed #10239 - Added docs for modelform_factory

Thanks ingenieroariel for the suggestion and slurms for the review.

Backport of 71d76ec011 from master

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