it's possible to write a filter by field in related object?

Issue #2 new
Pavel Sysolyatin
created an issue

For example, filter authors which books costs 3.55.

QuerySet filter like: {{{


Author.objects.all().filter(books__price=3.55) }}}

Comments (7)

  1. Luke Plant repo owner

    If you are asking about Django's query syntax, then yes it is possible.

    With django-easyfilters, currently it's not possible to do this kind of filtering. I haven't yet thought about how difficult it would be add this. Note that there are two different cases - the ForeignKey case and the ManyToMany case.

  2. Philippe Luickx

    Hi Luke,

    Apologies for bumping this old thread, but I am very curious to see what came out of here. Hoping to use easyfilters to filter on users, but all relations are reversed. So I have Skills, which have a ForeignKey to User, but I would like to filter on Users.

    Thanks for the great package!

  3. Luke Plant repo owner

    Hi zwervertje

    It sounds like you are looking for some kind of 'Reverse ForeignKey' filter, which is a bit different from what this ticket is about. Given that I've already done M2M, which is just as complex as reverse foreign key, this should be possible. I don't know when I will have the time to implement it though.


  4. evildmp

    I too would like to be able to span models, and thus have ways to filter through the choices on:

    • attributes of a ForeignKey
    • attributes of ManyToMany objects
    • attributes of reverse ForeignKey objects

    I thought I might be able to construct this with a lot of customisation, but I don't think it's possible as it stands. And, it looks like it would be pretty difficult.

  5. Log in to comment