Quickly style all of your inlines with formfield_for_dbfield
class PersonInline(admin.TabularInline):
model = Person
extra = 6
def formfield_for_dbfield(self, db_field, **kwargs):
attrs = { 'size': 15 }
if db_field.attname == 'interest_level':
attrs = { 'size': 2 }
kwargs['widget'] = forms.TextInput(attrs=attrs)
return super(PersonInline, self).formfield_for_dbfield(db_field,**kwargs)
I see this used for things like custom widgets, ReadOnlyWidget, ColoredWidget, etc, but I wanted a quick and dirty(?) way to fit more fields on my inlines, since the admin just overflows.
0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.