在 Django Admin 中为 PositiveIntegerField 增加输入框宽度的正确方法是什么?
更新
这些是我的文件:
模型.py
from django.db import models
class Report(models.Model):
datum = models.DateField(unique=True, help_text='Od koji je datuma izvjestaj.')
osiguranika = models.PositiveIntegerField(help_text='Broj osiguranika.')
/* lot of staf below*/
def __unicode__(self):
return str(self.datum)
表格.py
from django import forms
from hzmo_web.apps.hzmo.models import Report
class ReportForm(forms.ModelForm):
class Meta:
model = Report
def __init__(self, *args, **kw):
super(ReportForm, self).__init__(*args, **kw)
self.fields['osiguranika'].widget.attrs['class'] = 'form-text'
css
.form-text{
width:750px;
height:250px;
}