8000 Docs on per-object filtering · martync/django-rest-framework@4d48de6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4d48de6

Browse files
committed
Docs on per-object filtering
1 parent 5fffaf8 commit 4d48de6

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

docs/api-guide/filtering.md

Lines changed: 8 additions & 0 deletions
< F733 div data-testid="addition diffstat" class="DiffSquares-module__diffSquare--h5kjy DiffSquares-module__addition--jeNtt">
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,14 @@ For more details on using filter sets see the [django-filter documentation][djan
140140

141141
---
142142

143+
### Filtering and object lookups
144+
145+
Note that if a filter backend is configured for a view, then as well as being used to filter list views, it will also be used to filter the querysets used for returning a single object.
146+
147+
For instance, given the previous example, and a product with an id of `4675`, the following URL would either return the corresponding object, or return a 404 response, depending on if the filtering conditions were met by the given product instance:
148+
149+
http://example.com/api/products/4675/?category=clothing&max_price=10.00
150+
143151
## Overriding the initial queryset
144152

145153
Note that you can use both an overridden `.get_queryset()` and generic filtering together, and everything will work as expected. For example, if `Product` had a many-to-many relationship with `User`, named `purchase`, you might want to write a view like this:

docs/topics/release-notes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ You can determine your currently installed version using `pip freeze`:
4040

4141
## 2.2.x series
4242

43+
### Master
44+
45+
* Filtering backends are now applied to the querysets for object lookups as well as lists. (Eg you can use a filtering backend to control which objects should 404)
46+
4347
### 2.2.3
4448

4549
**Date**: 7th March 2013

0 commit comments

Comments
 (0)
0