AltSchool / dynamic-rest

Dynamic extensions for Django REST Framework
MIT License
820 stars 107 forks source link

How to negate a filter query? #355

Closed ridoo closed 7 months ago

ridoo commented 1 year ago

I want to filter data via DREST but want to exclude content having a particular attribute value. For example like so:

<url>/?filter{attribute.ne}}=bar

{
  id: "foo",
  attribute: "bar"
}

However, I saw that there is no operator ne defined here:

https://github.com/AltSchool/dynamic-rest/blob/ed69e5af4ddf153e6eb304b7db80cc6adbf4d654/dynamic_rest/filters.py#L190-L213

All of these filters are "positive" filters. Also, in the docs I have not found any reference to negate a query. Do I miss something?

ridoo commented 7 months ago

Any hints on this one? perhaps I am missing something essential here

ryochiji commented 7 months ago

The docs cover this but prepend the attribute name with -, e.g. filter{-attribute}=bar.

ridoo commented 7 months ago

@ryochiji interesting .. too simple to spot it :see_no_evil: Thanks! I will close this then.