As per Django widget classes (see this link for available types of widget/html input types):
from django import forms
from .models import MedicalRecords
class UpdateMedicalRecordForm(forms.ModelForm):
# we can directly specify attributes to individual fields like this
title = forms.CharField(max_length = 100, widget = forms.TextInput(attrs={'class':'title_class_name', 'id':'title_id'}))
file = forms.ImageField(widget = forms.FileInput(attrs={'class':'file_class_name', 'id':'file_id'}))
class Meta:
model = MedicalRecords
fields = ("title", "file", "doctor")
# or we can use widgets like this
widgets = {
"title": forms.Textarea(attrs={"rows": "", "class": "title_class_name"}),
"file": forms.FileInput(attrs={"rows": "", "class": "file_class_name"}),
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…