Opened 7 years ago

Closed 3 years ago

Last modified 3 years ago

#10239 closed New feature (fixed)

Document modelform_factory

Reported by: ingenieroariel Owned by: timo
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 willhardy 4 years ago.
Added documentation for modelform_factory
10239.diff (7.3 KB) - added by timo 3 years ago.

Download all attachments as: .zip

Change History (15)

comment:1 Changed 7 years ago by jacob

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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 5 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 4 years ago by SmileyChris

  • Severity set to Normal
  • Summary changed from Document modelform_factory to Document modelform_factory
  • Triage Stage changed from Accepted to Design decision needed
  • Type set to 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 4 years ago by willhardy

  • Easy pickings unset
  • Owner changed from nobody to willhardy
  • Status changed from new to assigned
  • UI/UX unset

Changed 4 years ago by willhardy

Added documentation for modelform_factory

comment:5 Changed 4 years ago by willhardy

  • Has patch set
  • Keywords dceu2011 added
  • Owner changed from willhardy to nobody
  • Status changed from assigned to new

comment:6 Changed 4 years ago by pterk

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

comment:7 Changed 4 years ago by gabrielhurley

  • Patch needs improvement set
  • Triage Stage changed from Design decision needed to Accepted

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 3 years ago by timo

  • Owner changed from nobody to timo

I'll add some reference docs to this.

Changed 3 years ago by timo

comment:9 Changed 3 years ago by timo

  • Patch needs improvement unset

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

comment:10 Changed 3 years ago by slurms

  • Triage Stage changed from Accepted to Ready for checkin

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

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

  • Resolution set to fixed
  • Status changed from new to closed

In 71d76ec011b393990ba9f5fb63727dbe36c3c440:

Fixed #10239 - Added docs for modelform_factory

Thanks ingenieroariel for the suggestion and slurms for the review.

comment:12 Changed 3 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 3 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