0

models.py

 PERSON_ACTIONS = (
        ('1', '01.Allowed to rest and returned to class'),
        ('2', '02.Contacted parents /guardians'),
        ('3', '02a.- Unable to Contact'),
        ('4', '02b.Unavailable - left message'))

class Actions(models.Model):    
    reportperson = models.ForeignKey(ReportPerson)
    action =  models.IntegerField('Action type', choices=PERSON_ACTIONS)

forms.py

class PersonActionsForm(forms.ModelForm):
    action = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple(), required=False)

    class Meta:
        model = Actions
        fields = ['action']

template

{{actionform.get_action_display}}

This is not showing the form data in human readable format.It is not rendering the integer value from db also.

user2086641
  • 4,331
  • 13
  • 56
  • 96

2 Answers2

0

I think you want that:

class PersonActionsForm(forms.ModelForm):

    class Meta:
        model = Actions
        fields = ('action',)
        widgets = {
            'action': forms.CheckboxSelectMultiple(),
        }

See here

Leandro
  • 2,217
  • 15
  • 18
0

Model.get_FOO_display()?

In case you wan't to render value from instance in form:

{{actionform.instance.get_action_display}}
draganHR
  • 2,578
  • 2
  • 21
  • 14