Python Django-从模板内的ModelChoiceField获取显示值

Python Django-从模板内的ModelChoiceField获取显示值,python,html,django,Python,Html,Django,因此,我有一个模板如下: <input class="form-control" id="{{ form.date.auto_id }}" name="{{ form.date.html_name }}" readonly="readonly" type="text" value="{{ form.date.value }}"> 如何在文本字段中获得实际的显示值,而不仅仅是主键?您能详细说明一下您的问题吗。 class DateChoiceField(forms.ModelChoi

因此,我有一个模板如下:

<input class="form-control" id="{{ form.date.auto_id }}" name="{{ form.date.html_name }}" readonly="readonly" type="text" value="{{ form.date.value }}">

如何在文本字段中获得实际的显示值,而不仅仅是主键?

您能详细说明一下您的问题吗。
class DateChoiceField(forms.ModelChoiceField):
    def label_from_instance(self, obj):
        return obj.date.strftime("%A %d. %B %Y")