Code Monkey home page Code Monkey logo

Comments (3)

miki725 avatar miki725 commented on June 13, 2024

not any simple way at the moment

from django-url-filter.

selimt avatar selimt commented on June 13, 2024

That's ok, it was as simple as adding the following:

    @form_field_for_filter(forms.CharField())
    def filter_exact_for_django(self, queryset, spec):
        value = json.loads(spec.value)
        f = queryset.filter if not spec.is_negated else queryset.exclude
        return f(status=value)

from django-url-filter.

tbitai avatar tbitai commented on June 13, 2024

In order to solve this problem, I wrote FallbackCallableFilter:

class FallbackCallableFilter(CallableFilter):
    def get_spec(self, config):
        spec = super(CallableFilter, self).get_spec(config)
        try:
            spec.filter_callable = self._get_filter_method_for_lookup(spec.lookup)
        except AttributeError:
            pass
        return spec

Perhaps this could be part of the project?

Note that @selimt's solution is not complete, as there are many other lookups besides __exact (__icontains, __in etc.).

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.