Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Properly check the class with isinstance

Roland Geider6819aebd7d06
diff --git a/wger/core/templatetags/wger_extras.py b/wger/core/templatetags/wger_extras.py
index e1ad1bced..eb5999e68 100644
--- a/wger/core/templatetags/wger_extras.py
+++ b/wger/core/templatetags/wger_extras.py
@@ -222,7 +222,7 @@ def is_checkbox(field):
:param field: a form field
:return: boolen
'''
- return field.field.widget.__class__.__name__ == CheckboxInput().__class__.__name__
+ return isinstance(field.field.widget, CheckboxInput)
@register.filter(name='is_multiple')
@@ -245,7 +245,7 @@ def is_fileupload(field):
:param field: a form field
:return: boolen
'''
- return field.field.widget.__class__.__name__ == ClearableFileInput().__class__.__name__
+ return isinstance(field.field.widget, ClearableFileInput)
@register.inclusion_tag('tags/render_form_element.html')