Ticket #11771: 11771.patch

File 11771.patch, 1.7 KB (added by sciyoshi, 6 years ago)
  • django/contrib/admin/validation.py

    diff --git a/django/contrib/admin/validation.py b/django/contrib/admin/validation.py
    index 50e4143..9eacb38 100644
    a b def validate(cls, model): 
    5757    if hasattr(cls, 'list_filter'):
    5858        check_isseq(cls, 'list_filter', cls.list_filter)
    5959        for idx, field in enumerate(cls.list_filter):
    60             get_field(cls, model, opts, 'list_filter[%d]' % idx, field)
     60            if not isinstance(field, models.Field):
     61                get_field(cls, model, opts, 'list_filter[%d]' % idx, field)
    6162
    6263    # list_per_page = 100
    6364    if hasattr(cls, 'list_per_page') and not isinstance(cls.list_per_page, int):
  • django/contrib/admin/views/main.py

    diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py
    index df0fd9f..37dc0fb 100644
    a b class ChangeList(object): 
    7474    def get_filters(self, request):
    7575        filter_specs = []
    7676        if self.list_filter:
    77             filter_fields = [self.lookup_opts.get_field(field_name) for field_name in self.list_filter]
    78             for f in filter_fields:
    79                 spec = FilterSpec.create(f, request, self.params, self.model, self.model_admin)
     77            for field in self.list_filter:
     78                if not isinstance(field, models.Field):
     79                    field = self.lookup_opts.get_field(field)
     80                spec = FilterSpec.create(field, request, self.params, self.model, self.model_admin)
    8081                if spec and spec.has_output():
    8182                    filter_specs.append(spec)
    8283        return filter_specs, bool(filter_specs)
Back to Top