-
-
Save mintchaos/249886 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@register.filter | |
def exclude_fields(form, field_names): | |
""" | |
Returns the fields of a Form excluding the named fields. Usage: | |
{% for field in form|exclude_fields:"field1,field2,field3" %} | |
""" | |
fields = [] | |
if isinstance(form, BaseForm): | |
field_names = field_names.split(',') | |
for field in form.fields: | |
if field not in field_names: | |
fields.append(BoundField(form, form.fields[field], field)) | |
return fields |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment