@@ -20,7 +20,7 @@ new class objects and `mypy` does not support such ways.
2020First, let's import all necessary components:
2121
2222``` py
23- {!../ docs_src/ tutorials_advanced/ customization.py [ln:1 - 9 ]!}
23+ {!../ docs_src/ tutorials_advanced/ customization.py [ln:1 - 12 ]!}
2424```
2525
2626Now we can customize our page.
@@ -30,7 +30,7 @@ Now we can customize our page.
3030If you want to change default name of page class, you should use ` UseName ` customizer:
3131
3232``` py
33- {!../ docs_src/ tutorials_advanced/ customization.py [ln:11 - 14 ]!}
33+ {!../ docs_src/ tutorials_advanced/ customization.py [ln:14 - 17 ]!}
3434```
3535
36361 . Now your class will be names 'IntPage' instead of 'CustomizedPage'.
@@ -47,7 +47,7 @@ By default, cursor-based page don't include total count of items, and offset-bas
4747If you want to change this behavior, you should use ` UseIncludeTotal ` customizer:
4848
4949``` py
50- {!../ docs_src/ tutorials_advanced/ customization.py [ln:16 - 19 ]!}
50+ {!../ docs_src/ tutorials_advanced/ customization.py [ln:19 - 22 ]!}
5151```
5252
53531 . Now when you will paginate using ` PageNoTotal ` class, it will not include total count of items.
@@ -57,7 +57,7 @@ If you want to change this behavior, you should use `UseIncludeTotal` customizer
5757If you want to change default values of pagination parameters, you should use ` UseParamsFields ` customizer:
5858
5959``` py
60- {!../ docs_src/ tutorials_advanced/ customization.py [ln:21 - 24 ]!}
60+ {!../ docs_src/ tutorials_advanced/ customization.py [ln:24 - 27 ]!}
6161```
6262
63631 . Now when ` size ` parameter is not provided, it will be equal to 500.
@@ -68,18 +68,51 @@ If you want to change default values of pagination parameters, you should use `U
6868If you want to change type of pagination parameters, you should use ` UseParams ` customizer:
6969
7070``` py
71- {!../ docs_src/ tutorials_advanced/ customization.py [ln:26 - 29 ]!}
71+ {!../ docs_src/ tutorials_advanced/ customization.py [ln:29 - 32 ]!}
7272```
7373
74741 . Now all pagination parameters will be optional.
7575
7676
77+ ### Change fields names
78+
79+ If you want use another name of field rather than default, you should use ` UseFieldsAliases ` customizer:
80+
81+ ``` py
82+ {!../ docs_src/ tutorials_advanced/ customization.py [ln:43 - 46 ]!}
83+ ```
84+
85+ 1 . Now ` total ` field will be serialized as ` count ` .
86+
87+
88+ ### Exclude fields
89+
90+ If you want to exclude some fields from serialization, you should use ` UseExcludedFields ` customizer:
91+
92+ ``` py
93+ {!../ docs_src/ tutorials_advanced/ customization.py [ln:48 - 51 ]!}
94+ ```
95+
96+ 1 . Now ` total ` field will not be serialized.
97+
98+
99+ ### Change pydantic model config
100+
101+ If you want to change pydantic model config, you should use ` UseModelConfig ` customizer:
102+
103+ ``` py
104+ {!../ docs_src/ tutorials_advanced/ customization.py [ln:53 - 56 ]!}
105+ ```
106+
107+ 1 . Now ` Page ` class will have ` anystr_lower ` set to ` True ` .
108+
109+
77110### Change page params type
78111
79112If you want to change type of page parameters, you should use ` UseParams ` customizer:
80113
81114``` py
82- {!../ docs_src/ tutorials_advanced/ customization.py [ln:31 - 39 ]!}
115+ {!../ docs_src/ tutorials_advanced/ customization.py [ln:35 - 41 ]!}
83116```
84117
851181 . Now ` Page.__params_type__ ` attribute will be point to ` MyParams ` class.
@@ -90,7 +123,7 @@ If you want to change type of page parameters, you should use `UseParams` custom
90123You can use multiple customizers at once, just pass them as to regular ` Annotated ` :
91124
92125``` py
93- {!../ docs_src/ tutorials_advanced/ customization.py [ln:41 - 47 ]!}
126+ {!../ docs_src/ tutorials_advanced/ customization.py [ln:58 - 63 ]!}
94127```
95128
961291 . Now ` CustomPage ` will have ` CustomPage ` name, no total count of items, all params optional.
0 commit comments