Comments (2)
I'd upvote this for implementation. Can't imagine it's too hard, though may need to support a slightly richer URL syntax. Currently:
http://site.tld/model?field1=val1&field2_lt=val&field3_gt=val3
is all AND logic. To support OR logic we could introduce a new syntax. Just floating an idea it could be as simple as introducing some new URL parameters, like and and or
http://site.tld/model?field1=val1&and&field2_lt=val2&or&field3_gt=val3
That's possible because order exists on the URL and I'd moot that such a string would be parsed right to producing:
Q(field1=val1) & (Q(field2_lt=val2) | Q(field3_gt=val3) )
Of course for true generality we'd need to be able to group items on the URL, but by same reasoning, two parameters, lb and rb perhaps can encode braces.
Alternately the whole thing can be encoded in one parameter "filter" with one of the very few URL friendly chars as a delimiter:
http://site.tld/model?filter=lb~field1~val1~and~field2_lt~val2~rb~or~field3_gt=val3
might parse to:
(Q(field1=val1) & Q(field2_lt=val2)) | Q(field3_gt=val3)
Anyhow, I think supporting OR logic on the URL would be a major value add to django-url-filter.
Just my thoughts anyhow.
from django-url-filter.
currently thats not possible out of the box. but you can do custom filters via callable filters - https://django-url-filter.readthedocs.io/en/latest/api/url_filter.filters.html#url_filter.filters.CallableFilter
from django-url-filter.
Related Issues (20)
- lookups not limited according to field type
- __icontains is not working on list // arrayfields HOT 1
- Deprecated method ungettet_lazy HOT 9
- Filtering from custom DRF actions HOT 1
- Enabling all fields filtering by default
- Ignore empty fields HOT 1
- How can I filter with OR condition?
- UUID filter with lookup startswith HOT 4
- Package maintenance HOT 4
- Not compatible with Django 4.2.1 HOT 3
- ArrayField Support of Postgresql
- Fix the docs in url_filter/integrations/drf_coreapi.py HOT 2
- UTC datetimes in the database queried against the
- Support for []-style array arguments
- ISO datatime format HOT 2
- DateTime __date filter not working HOT 6
- CoreAPIURLFilterBackend causing recursion depth exceeded HOT 5
- Filtering on email field throws ValidationError HOT 1
- Error when trying to filter by a date range of a datetime field HOT 1
- How can I shorten the request
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-url-filter.