The 'official' way is to use exactly the same principles as with a
form. You just define a custom model form, overriding the particular
field, then use that form in the admin options for that model:
class MyCustomForm(forms.ModelForm):
myfield =
forms.CharField(widget=forms.TextField(attrs={'class':'myclass'}))
class MyCustomAdmin(admin.ModelAdmin):
form = MyCustomForm
admin.site.register(MyModel, MyCustomAdmin)
Another way to do it would be to put the custom class on an entire
fieldset, rather than the field:
class MyCustomAdmin(admin.ModelAdmin):
fieldsets = (
('My custom fields', {
'fields': ('myfield',)
'classes': ('myclass',)
}
),
('My other fields', {
'fields': ('field1', 'field2', 'field3')
}
),
)
--
DR.