Skip to content

Commit 50868b8

Browse files
committed
Updated pagination part in the Quick Example doc
1 parent 6980aeb commit 50868b8

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

docs/api_controller/index.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
APIController is a borrowed term from the C# ASP.NET environment which is an MVC framework. Although Django is not an MVC framework, we can still mimic the concept generally just like any other programming concept.
44

5-
Django-Ninja-Extra APIController is modelled after C# ASP.NET ApiController, giving all OOP sense in creating your controller models and adapting recent software design patterns in your Django project.
5+
Django-Ninja-Extra APIController is modelled after C# ASP.NET ApiController, giving all OOP sense in creating your controller models and adapting recent software design patterns in your Django project.
66

77
### Why APIController in Django.
8+
89
I come from a background where we model anything in class based object, and I have worked with many API tools out there in python: DRF, FastAPI, Flask-Restful. It is either function based or class tailored to function based.
910
Don't get me wrong, there are still great libraries. In fact, some features of Django-Ninja-Extra came from DRF. So I am a big fan. I needed more.
1011

@@ -14,18 +15,20 @@ So I designed APIController to extend Django-Ninja to class-based and have somet
1415

1516
So if you enjoy class-based controls for building API, welcome aboard.
1617

17-
1818
## ControllerBase
19+
1920
```python
2021
class ControllerBase(ABC):
2122
...
2223
```
24+
2325
APIController decorates any class with `ControllerBase` if its not inheriting from it.
2426

2527
!!!info
26-
Inheriting from ControllerBase class gives you more IDE intellisense support.
28+
Inheriting from ControllerBase class gives you more IDE intellisense support.
2729

2830
## Quick Example
31+
2932
Let's create an APIController to manage Django user model
3033

3134
```python
@@ -66,9 +69,9 @@ class UsersController(ControllerBase):
6669
user = self.get_object_or_exception(self.user_model, id=user_id)
6770
user.delete()
6871
return self.create_response('', status_code=status.HTTP_204_NO_CONTENT)
69-
70-
@http_get('', response=List[UserSchema])
71-
@pagination.paginate
72+
73+
@http_get('', response=pagination.PaginatedResponseSchema[UserSchema])
74+
@pagination.paginate(pagination.PageNumberPaginationExtra, page_size=50)
7275
def list_user(self):
7376
return self.user_model.objects.all()
7477

0 commit comments

Comments
 (0)