add fields method limiting the models columns fetched from db

This commit is contained in:
collerek
2020-10-05 09:40:41 +02:00
parent 16b8e95975
commit 287b970a09
16 changed files with 209 additions and 38 deletions

View File

@ -76,7 +76,7 @@ track = Track.objects.filter(name="The Bird").get()
# will return a track with name equal to 'The Bird'
tracks = Track.objects.filter(album__name="Fantasies").all()
# will return all tracks where the related album name = 'Fantasies'
# will return all tracks where the columns album name = 'Fantasies'
```
You can use special filter suffix to change the filter operands:
@ -106,7 +106,7 @@ To chain related `Models` relation use double underscore.
```python
album = await Album.objects.select_related("tracks").all()
# will return album will all related tracks
# will return album will all columns tracks
```
You can provide a string or a list of strings