fix quoting in order_by, add get_or_none

This commit is contained in:
collerek
2021-03-23 17:36:20 +01:00
parent b08d616dc0
commit 4ad843a6a5
14 changed files with 214 additions and 2 deletions

View File

@ -5,6 +5,7 @@ You can use following methods to filter the data (sql where clause).
* `filter(**kwargs) -> QuerySet`
* `exclude(**kwargs) -> QuerySet`
* `get(**kwargs) -> Model`
* `get_or_none(**kwargs) -> Optional[Model]`
* `get_or_create(**kwargs) -> Model`
* `all(**kwargs) -> List[Optional[Model]]`
@ -13,6 +14,7 @@ You can use following methods to filter the data (sql where clause).
* `QuerysetProxy.filter(**kwargs)` method
* `QuerysetProxy.exclude(**kwargs)` method
* `QuerysetProxy.get(**kwargs)` method
* `QuerysetProxy.get_or_none(**kwargs)` method
* `QuerysetProxy.get_or_create(**kwargs)` method
* `QuerysetProxy.all(**kwargs)` method
@ -397,6 +399,11 @@ When any kwargs are passed it's a shortcut equivalent to calling `filter(**kwarg
To read more about `get` go to [read/get](../read/#get)
## get_or_none
Exact equivalent of get described above but instead of raising the exception returns `None` if no db record matching the criteria is found.
## get_or_create
`get_or_create(**kwargs) -> Model`
@ -461,6 +468,11 @@ objects from other side of the relation.
!!!tip
To read more about `QuerysetProxy` visit [querysetproxy][querysetproxy] section
#### get_or_none
Exact equivalent of get described above but instead of raising the exception returns `None` if no db record matching the criteria is found.
#### get_or_create
Works exactly the same as [get_or_create](./#get_or_create) function above but allows

View File

@ -46,6 +46,7 @@ To read more about any specific section or function please refer to the details
### [Read data from database](./read.md)
* `get(**kwargs) -> Model`
* `get_or_none(**kwargs) -> Optional[Model]`
* `get_or_create(**kwargs) -> Model`
* `first() -> Model`
* `all(**kwargs) -> List[Optional[Model]]`
@ -57,6 +58,7 @@ To read more about any specific section or function please refer to the details
* `QuerysetProxy`
* `QuerysetProxy.get(**kwargs)` method
* `QuerysetProxy.get_or_none(**kwargs)` method
* `QuerysetProxy.get_or_create(**kwargs)` method
* `QuerysetProxy.first()` method
* `QuerysetProxy.all(**kwargs)` method
@ -122,6 +124,7 @@ To read more about any specific section or function please refer to the details
* `exclude(**kwargs) -> QuerySet`
* `order_by(columns:Union[List, str]) -> QuerySet`
* `get(**kwargs) -> Model`
* `get_or_none(**kwargs) -> Optional[Model]`
* `get_or_create(**kwargs) -> Model`
* `all(**kwargs) -> List[Optional[Model]]`
@ -131,6 +134,7 @@ To read more about any specific section or function please refer to the details
* `QuerysetProxy.exclude(**kwargs)` method
* `QuerysetProxy.order_by(columns:Union[List, str])` method
* `QuerysetProxy.get(**kwargs)` method
* `QuerysetProxy.get_or_none(**kwargs)` method
* `QuerysetProxy.get_or_create(**kwargs)` method
* `QuerysetProxy.all(**kwargs)` method

View File

@ -55,6 +55,13 @@ track == track2
If there are multiple rows meeting the criteria the `MultipleMatches` exception is raised.
## get_or_none
`get_or_none(**kwargs) -> Model`
Exact equivalent of get described above but instead of raising the exception returns `None` if no db record matching the criteria is found.
## get_or_create
`get_or_create(**kwargs) -> Model`
@ -190,6 +197,14 @@ objects from other side of the relation.
!!!tip
To read more about `QuerysetProxy` visit [querysetproxy][querysetproxy] section
### get_or_none
Exact equivalent of get described above but instead of raising the exception returns `None` if no db record matching the criteria is found.
!!!tip
To read more about `QuerysetProxy` visit [querysetproxy][querysetproxy] section
### get_or_create
Works exactly the same as [get_or_create](./#get_or_create) function above but allows