Code Monkey home page Code Monkey logo

Comments (2)

bernd-wechner avatar bernd-wechner commented on June 6, 2024 1

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.

miki725 avatar miki725 commented on June 6, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.