【发布时间】:2020-07-13 17:51:33
【问题描述】:
我正在显示一个带有小时数的选择框。这个时间是固定的,来自 db。为此,我在models.py 中使用了models.TimeField。现在在html 页面中,这些时间显示为14:00:00。我想删除秒。这是我的代码:
models.py:
class MeetingHour(models.Model):
hour = models.TimeField()
def __str__(self):
return str(self.hour)
html:
<select>
{% for meetinghour in meetinghours %}
<option value="{{meetinghour}}">{{meetinghour}}</option>
{% endfor %}
</select>
【问题讨论】:
标签: python django django-models django-views django-templates