modelform_factory should accept widgets argument
|Reported by:||SardarNL||Owned by:||nobody|
|Cc:||AndrewIngram||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
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.
Change History (12)
comment:1 Changed 6 years ago by
|Patch needs improvement:||set|
|Triage Stage:||Unreviewed → Accepted|
comment:3 Changed 6 years ago by
|Owner:||changed from nobody to Will Hardy|
|Status:||new → assigned|