如何将django模型中的TimeField格式设置为[min:sec],就像音轨一样?
class Song(models.Model):
title = models.CharField(max_length=128)
duration = models.TimeField(null=True)
答案 0 :(得分:0)
在app中创建form.py并在视图中继承此表单如果你想在admin中使用相同的概念,那么也在django admin中继承
from django import forms
from .models import Song
class SongForm(forms.ModelForm):
duration = forms.TimeField(widget=forms.TimeInput(format='%H:%M'))
class Meta:
model = Song