diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index 1f8ff6d..6fe494e 100644
a
|
b
|
class BaseModelAdmin(object):
|
73 | 73 | overrides.update(self.formfield_overrides) |
74 | 74 | self.formfield_overrides = overrides |
75 | 75 | |
| 76 | def formfield_changelist_for_dbfield(self, db_field, **kwargs): |
| 77 | """ |
| 78 | Hook for specifying the form Field instance for a given database Field |
| 79 | instance when using 'list_editable' on the changelist. |
| 80 | |
| 81 | By default, returns formfield_for_dbfield. |
| 82 | """ |
| 83 | return self.formfield_for_dbfield(db_field, **kwargs) |
| 84 | |
76 | 85 | def formfield_for_dbfield(self, db_field, **kwargs): |
77 | 86 | """ |
78 | 87 | Hook for specifying the form Field instance for a given database Field |
… |
… |
class ModelAdmin(BaseModelAdmin):
|
392 | 401 | Returns a Form class for use in the Formset on the changelist page. |
393 | 402 | """ |
394 | 403 | defaults = { |
395 | | "formfield_callback": curry(self.formfield_for_dbfield, request=request), |
| 404 | "formfield_callback": curry(self.formfield_changelist_for_dbfield, request=request), |
396 | 405 | } |
397 | 406 | defaults.update(kwargs) |
398 | 407 | return modelform_factory(self.model, **defaults) |
… |
… |
class ModelAdmin(BaseModelAdmin):
|
403 | 412 | is used. |
404 | 413 | """ |
405 | 414 | defaults = { |
406 | | "formfield_callback": curry(self.formfield_for_dbfield, request=request), |
| 415 | "formfield_callback": curry(self.formfield_changelist_for_dbfield, request=request), |
407 | 416 | } |
408 | 417 | defaults.update(kwargs) |
409 | 418 | return modelformset_factory(self.model, |
diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt
index 7fee903..942c926 100644
a
|
b
|
you can pass a ``cacheable=True`` argument to :meth:`AdminSite.admin_view`::
|
853 | 853 | |
854 | 854 | (r'^my_view/$', self.admin_site.admin_view(self.my_view, cacheable=True)) |
855 | 855 | |
| 856 | .. method:: ModelAdmin.formfield_for_dbfield(self, db_field, **kwargs) |
| 857 | |
| 858 | The ``formfield_for_dbfield`` method on a ``ModelAdmin`` allows you to |
| 859 | override the default formfield used for a given database field. |
| 860 | |
| 861 | .. method:: ModelAdmin.formfield_changelist_for_dbfield(self, db_field, **kwargs) |
| 862 | |
| 863 | .. versionadded:: 1.3 |
| 864 | |
| 865 | The ``formfield_changelist_for_dbfield`` method on a ``ModelAdmin`` allows you to |
| 866 | override the default formfields used on a changelist page when list_editable is enabled. |
| 867 | Use this method to override a formfield only on the changelist. For example, to set |
| 868 | a CSS class for certain fields:: |
| 869 | |
| 870 | class MyModelAdmin(admin.ModelAdmin): |
| 871 | def formfield_changelist_for_dbfield(self, db_field, **kwargs): |
| 872 | field = super(MyModelAdmin, self).formfield_changelist_for_dbfield(db_field, **kwargs) |
| 873 | if db_field.name in ('short_field_1', 'short_field_2'): |
| 874 | field.widget.attrs['class']='smaller' |
| 875 | return field |
| 876 | |
| 877 | By default, this method just returns the result of ``formfield_for_dbfield``. |
| 878 | |
856 | 879 | .. method:: ModelAdmin.formfield_for_foreignkey(self, db_field, request, **kwargs) |
857 | 880 | |
858 | 881 | .. versionadded:: 1.1 |