1

What is the best way to change text field size in Grappelli?

Standard text field with vTextField class is 758px width. I looks strange when used for phone number field.

I have figured out that one possibility is inject style attribute into form meta.

class CompanyForm(ModelForm):

class Meta:
    model = Company
    widgets = {
        'phone': TextInput(attrs={'size': 13}),
        'tax_id': TextInput(attrs={'size': 6}),
        'zip': TextInput(attrs={'size': 6, 'style' : 'width: 80px'}),
    }

I am not sure this is the best solution and ....I do not like this (using style inline). Is there any other in the box solution?

4

1 回答 1

1

在模型管理中定义自定义样式表(媒体属性)

<style type="text/css">
    #id_phone { 
        width: 100px; !important
        }
    .......
</style>
于 2013-03-09T00:16:22.660 回答