Opened 14 years ago
Closed 13 years ago
#15315 closed New feature (fixed)
modelform_factory should accept widgets argument
Reported by: | SardarNL | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | 1.2 |
Severity: | Normal | Keywords: | dceu2011 |
Cc: | AndrewIngram | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Since Django 1.2 model forms can override widgets by specifying 'widgets' attribute in Meta, similar to 'fields' or 'exclude'. The modelform_factory doesn't accept widgets, so the only way to specify it is by defining a new parent ModelForm with Meta and giving it as 'form' argument. This is more complex than it needs to be.
The fix is to add new keyword argument widgets=None and add:
if widgets is not None: attrs['widgets'] = widgets
right after similar if for 'exclude'. This will add 'widgets' attribute to dynamically created Meta.
Attachments (2)
Change History (12)
by , 14 years ago
Attachment: | models.py.diff added |
---|
comment:1 by , 14 years ago
milestone: | 1.3 |
---|---|
Needs tests: | set |
Patch needs improvement: | set |
Triage Stage: | Unreviewed → Accepted |
Three points:
- This is a new feature, so it can't be on the 1.3 milestone
- Please use unified diffs (i.e., the format generated by svn diff), rather than context diffs
- Any patch for a new feature requires tests.
comment:2 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:3 by , 13 years ago
Easy pickings: | unset |
---|---|
Owner: | changed from | to
Status: | new → assigned |
UI/UX: | unset |
by , 13 years ago
Attachment: | ticket15315.patch added |
---|
Updated the diff to the current trunk and added a test
comment:4 by , 13 years ago
Needs tests: | unset |
---|---|
Patch needs improvement: | unset |
comment:5 by , 13 years ago
Keywords: | dceu2011 added |
---|
comment:6 by , 13 years ago
Owner: | changed from | to
---|---|
Status: | assigned → new |
comment:7 by , 13 years ago
This patch should probably also update the docs(tring) if/when #10239 is applied?
comment:8 by , 13 years ago
Cc: | added |
---|
comment:9 by , 13 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
simple patch