newforms field callback helper

 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

  1. Javascript Chain Select Widget by ogo 3 years, 11 months ago
  2. Automatically trim newforms text fields by miracle2k 4 years, 8 months ago
  3. Natural language date/time form fields by jdriscoll 4 years, 11 months ago
  4. newforms and ModelForm by danfairs 4 years, 4 months ago
  5. ModelForm-based create_update generic views by carljm 3 years, 10 months ago

Comments

(Forgotten your password?)