1 2 3 4 5 6 7 8 9 10 11 | def new_callback(exclude=None, include=None):
"""
Create a form callback which excludes or only includes certain fields.
"""
def _callback(field, **kwargs):
if include and field.name not in include:
return None
if exclude and field.name in exclude:
return None
return field.formfield(**kwargs)
return _callback
|
More like this
- Convert an instance to a dictionary for use in newforms by SmileyChris 6 years, 1 month ago
- Serializing booleans correctly when doing dumpdata from a MySQL database using Django 0.96 by chrj 4 years, 10 months ago
- Modify fields created by form_for_model by grahamu 6 years, 3 months ago
- Add validation for 'unique' and 'unique_together' constraints to newforms created dynamically via form_for_model or form_for_instance by bikeshedder 6 years ago
- {% with %} template tag by SmileyChris 6 years, 2 months ago
Comments