#26254: Support for disallowing filter on local fields in ModelAdmin ----------------------------------+-------------------- Reporter: DheerendraRathor | Owner: nobody Type: New feature | Status: new Component: contrib.admin | Version: master Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 ----------------------------------+-------------------- Currently, if a local field is not present in `list_filter` and filter is called on that particular field directly in URL, it is allowed to filter on that particular field. But, if filter is called on a relational field which is not present in `list_filter`, filter is disallowed on that particular field.
This feature request is in support for disallowing filter on certain fields. This can be done by either not allowing filter on a field if field is not mentioned in `list_filter` or by adding an extra ModelAdmin field `disallowed_lookups`. But disallowing on the basis of list_filter might break admin for sites heavily relying on admin, second option will be better in my opinion. {{{ # An example fix if len(relation_parts) <= 1: # Either a local field filter, or no fields at all. if len(relation_parts) == 1 and relation_parts[0] in self.disallowed_lookups: return False return True }}} -- Ticket URL: <https://code.djangoproject.com/ticket/26254> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/059.5f16064725e5c7d30f974fb207f2e753%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.