if you have a Form.ModelForm with a choice field, you can itrate it in the template by a simple template filter.
forms.py
STATE_CHOICES = (
(10, 'NO'),
(4, 'YES'),
(18, 'Send to another Chemist for Review'),
(34, 'Send to another Market Expert for Review'),
(20, 'HOLD'),
)
new_state = forms.ChoiceField(
choices=STATE_CHOICES,
required=True,
)
Template:
{{ business_manager_form.new_state|filter_project_states:project }}
and here is the filter it self.
@register.filter()
def filter_project_states(argv, project):
if project.department.id != 4:
argv.field.choices = [choice for choice in argv.field.choices if choice[0] != 34]
return argv
I hope this helps.