表格.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 PersonActionsForm(forms.ModelForm):
action = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple(), choices=PERSON_ACTIONS, required=False)
视图.py
def person(request):
action= Actions.objects.filter(reportperson=person_id)
return render(request, 'index.html',
{
'action':action,
})
模型.py
class Actions(models.Model):
"""Action list to a report"""
reportperson = models.ForeignKey(ReportPerson)
action = models.IntegerField('Action type',choices=PERSON_ACTIONS)
模板
{{ action.get_action_display }}
从django doc中选择字段,我这样做了,但它不起作用。在数据库中,它们的值保存为“3”,“4”。我希望它会显示像“02a.-无法联系”这样的值,” 02b.Unavailable - left message”而不是“3”,“4”等。它没有显示任何东西。
如何使这项工作。
谢谢