The Django admin URL query string is "OR". Is it possible?

I like to write fast and dirty query strings directly to the Django admin URL. For example: /admin/myapp/mymodel/?pub_date__year=2011

Operators

AND are just as simple: /admin/myapp/mymodel/?pub_date__year=2011&author=Jim

I am wondering if the "OR" operator can be returned via the URL. Has anyone heard of such functionality?

+4
source share
2 answers

Django <1.4 does not support OR queries. Sometimes it is possible to translate OR queries into __in queries that are supported (they are equivalent to OR queries, but only for values โ€‹โ€‹of one field).

You can also upgrade to the django development version: it has a more universal list_filter implementation (see https://docs.djangoproject.com/en/dev//ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_filter ) , which can be used to provide advanced admin filters (including OR requests).

+4
source

And this is not logical And, although it seems that this is the case in your case. I am pretty sure that there is no way to create a logical OR in the GET request line.

+4
source

Source: https://habr.com/ru/post/1382535/


All Articles