I’m overriding fields in Django admin like this:
class MyPageAdmin(FlatPageAdmin):
def formfield_for_dbfield(self, db_field, **kwargs):
if db_field.name == 'url':
return db_field.formfield(widget=forms.TextInput(attrs={'size': 100}))
if db_field.name == 'title':
return db_field.formfield(widget=forms.TextInput(attrs={'size': 150}))
return super(MyPageAdmin, self).formfield_for_dbfield(db_field, **kwargs)
admin.site.unregister(FlatPage)
admin.site.register(MyPage, MyPageAdmin)
Now, the problem is that for the "Title" field in Django admin, the field width changes just as expected – size attribute is set to 150, but for the URL field, there’s absolutely now change. Yet, the code does run into the specific if statement, so the URL field is definitely there, but for the life of me, I cannot figure out, why only this field is unaffected by the override. Other fields do not suffer this problem (I have other overrides besides the "Title" field, but only the URL is stuck in its original size).