Search code examples
djangodjango-admindjango-modeltranslation

Django admin filter urls for not-equals


I've created a custom FieldListFilter for my site's admin for whether modeltranslation translations are available for a field.

It creates a filter that currently looks like this on the sidebar:

The "Lacks English" option adds vt_title_en__exact= to the query string.

I would like to also implement a "Has English" which does the opposite filter. Can I do that with a django admin site url query strings?

Btw: source for my custom filter: https://github.com/yairchu/azlemi/blob/master/vote/admin.py#L30


Solution

  • I think vt_title_en__gt= can do the job. Any non-empty string is greater than "".