Created
August 4, 2016 09:59
-
-
Save vitorfs/d361f88fd05e9800bd272c004961e790 to your computer and use it in GitHub Desktop.
Django Field Type Filter
This file contains hidden or 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
{% load fieldtype %} | |
{% for field in form.visible_fields %} | |
{% if field|fieldtype == 'CheckboxInput' %} | |
... | |
{% elif field|fieldtype == 'CheckboxSelectMultiple' %} | |
... | |
{% endif %} | |
... | |
{% endfor %} |
This file contains hidden or 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
from django import template | |
register = template.Library() | |
@register.filter('fieldtype') | |
def fieldtype(field): | |
return field.field.widget.__class__.__name__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment