Ticket #9119: ignore_non_field_params_against_9066.diff

File ignore_non_field_params_against_9066.diff, 1.0 KB (added by fas, 7 years ago)

Only use field lookup parameters to filter the results, ignore others.

  • django/contrib/admin/views/main.py

     
    181181                # 'key' will be used as a keyword argument later, so Python
    182182                # requires it to be a string.
    183183                del lookup_params[key]
    184                 lookup_params[smart_str(key)] = value
     184                key = smart_str(key)
     185                lookup_params[key] = value
    185186
     187            # ignore parameters that are no field lookups
     188            from django.db.models.sql.constants import LOOKUP_SEP
     189            try:
     190                field = self.opts.get_field(key.split(LOOKUP_SEP)[0])
     191            except models.FieldDoesNotExist:
     192                del lookup_params[key]
     193                continue
     194
    186195            # if key ends with __in, split parameter into separate values
    187196            if key.endswith('__in'):
    188197                lookup_params[key] = value.split(',')
Back to Top