When working with a reverse inline what is the best way to override form field properties? For example an Address model with a zip_code field being displayed as a Reverse Inline for a Customer Model. How would I go about getting the zip_code field reference in order to reduce the size of it's input box? The standard overriding get_form on the CustomerAdmin results in a keyerror.
def get_form(self, request, obj=None, **kwargs): form = super(CustomerAdmin, self).get_form(request, obj, **kwargs) form.base_fields['zip_code'].widget.attrs['style'] = 'width: 45em;' return form
When working with a reverse inline what is the best way to override form field properties? For example an Address model with a zip_code field being displayed as a Reverse Inline for a Customer Model. How would I go about getting the zip_code field reference in order to reduce the size of it's input box? The standard overriding get_form on the CustomerAdmin results in a keyerror.
def get_form(self, request, obj=None, **kwargs): form = super(CustomerAdmin, self).get_form(request, obj, **kwargs) form.base_fields['zip_code'].widget.attrs['style'] = 'width: 45em;' return form