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?

mrok
  • 2,680
  • 3
  • 27
  • 46

1 Answers1

1

Define custom stylesheets within your model admin (media property)

<style type="text/css">
    #id_phone { 
        width: 100px; !important
        }
    .......
</style>
catherine
  • 22,492
  • 12
  • 61
  • 85