Ticket #11651: customize_list_editable.diff

File customize_list_editable.diff, 1.6 KB (added by Adam Vandenberg, 10 years ago)
  • django/contrib/admin/options.py

    diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
    index 31a28cc..36cfefd 100644
    a b class BaseModelAdmin(object): 
    6767
    6868    def __init__(self):
    6969        self.formfield_overrides = dict(FORMFIELD_FOR_DBFIELD_DEFAULTS, **self.formfield_overrides)
     70       
     71    def formfield_changelist_for_dbfield(self, db_field, **kwargs):
     72        """
     73        Hook for specifying the form Field instance for a given database Field
     74        instance when using 'list_editable' on the changelist.
     75       
     76        By default, returns formfield_for_dbfield.
     77        """
     78        return self.formfield_for_dbfield(db_field, **kwargs)
    7079
    7180    def formfield_for_dbfield(self, db_field, **kwargs):
    7281        """
    class ModelAdmin(BaseModelAdmin): 
    352361        Returns a Form class for use in the Formset on the changelist page.
    353362        """
    354363        defaults = {
    355             "formfield_callback": curry(self.formfield_for_dbfield, request=request),
     364            "formfield_callback": curry(self.formfield_changelist_for_dbfield, request=request),
    356365        }
    357366        defaults.update(kwargs)
    358367        return modelform_factory(self.model, **defaults)
    class ModelAdmin(BaseModelAdmin): 
    363372        is used.
    364373        """
    365374        defaults = {
    366             "formfield_callback": curry(self.formfield_for_dbfield, request=request),
     375            "formfield_callback": curry(self.formfield_changelist_for_dbfield, request=request),
    367376        }
    368377        defaults.update(kwargs)
    369378        return modelformset_factory(self.model,
Back to Top