Code Monkey home page Code Monkey logo

Comments (8)

miki725 avatar miki725 commented on June 7, 2024

http://127.0.0.1:8000/api/customers/?in_use__iexact=no will work

from django-url-filter.

rajesh-h avatar rajesh-h commented on June 7, 2024

@miki725 Thank you I did see it works.

But is there a way to override in_use=no should be considered as iexact instead of exact.

I saw this method here for exact, I was thinking if I can override this on my side to iexact should work, but I was not successful here. :(

from django-url-filter.

miki725 avatar miki725 commented on June 7, 2024

you can do:

class CustomerFilterSet(FilterSet):
    in_use = Filter(form_field=forms.CharField(), default_lookup='iexact')

from django-url-filter.

miki725 avatar miki725 commented on June 7, 2024

relevant docs https://django-url-filter.readthedocs.io/en/latest/api/url_filter.filters.html#url_filter.filters.Filter

from django-url-filter.

rajesh-h avatar rajesh-h commented on June 7, 2024

@miki725 Thank you for the right direction. Is there a option to set default_lookup to iexact on api level or on model level?

Setting this on a field level is not a ideal situation in my case.

Once again thanks a lot for your help.

from django-url-filter.

miki725 avatar miki725 commented on June 7, 2024

what do you mean api level?

from django-url-filter.

rajesh-h avatar rajesh-h commented on June 7, 2024

@miki725 apologies i missed this comment.

When i say api level, i mean option to set all fields to case insensitive rather than setting per field basis like the example which is provided.
the example provided deals with fields level not on entire model level, so I was thinking an option to set on entire api level what should be the default filter exact or iexact or contains or icontains
eg: default_filter = 'iexact' #this will be global setting

Thanks

from django-url-filter.

miki725 avatar miki725 commented on June 7, 2024

that could be possible although its not that simple. iexact only makes sense for string fields. so the default will only have to apply where iexact is possible. but yes that could definitely be added as an improvement

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.