django-ninja-aio-crud 0.2.0__py3-none-any.whl → 0.2.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {django_ninja_aio_crud-0.2.0.dist-info → django_ninja_aio_crud-0.2.1.dist-info}/METADATA +17 -16
- {django_ninja_aio_crud-0.2.0.dist-info → django_ninja_aio_crud-0.2.1.dist-info}/RECORD +5 -4
- ninja_aio/__init__.py +5 -1
- ninja_aio/api.py +48 -0
- {django_ninja_aio_crud-0.2.0.dist-info → django_ninja_aio_crud-0.2.1.dist-info}/WHEEL +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: django-ninja-aio-crud
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Django Ninja AIO CRUD - Rest Framework
|
|
5
5
|
Author: Giuseppe Casillo
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -130,20 +130,21 @@ class Foo(ModelSerializer):
|
|
|
130
130
|
|
|
131
131
|
- post create method is a custom method that comes out to handle actions which will be excuted after that the object is created. It can be used, indeed, for example to handle custom fields' actions.
|
|
132
132
|
|
|
133
|
+
|
|
133
134
|
### APIViewSet
|
|
134
135
|
|
|
135
|
-
- View class used to automatically generate CRUD views. in your views.py import APIViewSet and define your api using
|
|
136
|
+
- View class used to automatically generate CRUD views. in your views.py import APIViewSet and define your api using NinjaAIO class. NinjaAIO class uses built-in parser and renderer which use orjson for data serialization.
|
|
136
137
|
|
|
137
138
|
```Python
|
|
138
139
|
# views.py
|
|
139
|
-
from
|
|
140
|
+
from ninja_aio import NinjaAIO
|
|
140
141
|
from ninja_aio.views import APIViewSet
|
|
141
142
|
from ninja_aio.parsers import ORJSONParser
|
|
142
143
|
from ninja_aio.renders import ORJSONRender
|
|
143
144
|
|
|
144
145
|
from .models import Foo
|
|
145
146
|
|
|
146
|
-
api =
|
|
147
|
+
api = NinjaAIO()
|
|
147
148
|
|
|
148
149
|
|
|
149
150
|
class FooAPI(APIViewSet):
|
|
@@ -158,14 +159,15 @@ FooAPI().add_views_to_route()
|
|
|
158
159
|
|
|
159
160
|
```Python
|
|
160
161
|
# views.py
|
|
161
|
-
from ninja import
|
|
162
|
+
from ninja import Schema
|
|
163
|
+
from ninja_aio import NinjaAIO
|
|
162
164
|
from ninja_aio.views import APIViewSet
|
|
163
165
|
from ninja_aio.parsers import ORJSONParser
|
|
164
166
|
from ninja_aio.renders import ORJSONRender
|
|
165
167
|
|
|
166
168
|
from .models import Foo
|
|
167
169
|
|
|
168
|
-
api =
|
|
170
|
+
api = NinjaAIO()
|
|
169
171
|
|
|
170
172
|
|
|
171
173
|
class ExampleSchemaOut(Schema):
|
|
@@ -196,12 +198,13 @@ FooAPI().add_views_to_route()
|
|
|
196
198
|
|
|
197
199
|
```Python
|
|
198
200
|
# views.py
|
|
199
|
-
from ninja import
|
|
201
|
+
from ninja import Schema
|
|
202
|
+
from ninja_aio import NinjaAIO
|
|
200
203
|
from ninja_aio.views import APIView
|
|
201
204
|
from ninja_aio.parsers import ORJSONParser
|
|
202
205
|
from ninja_aio.renders import ORJSONRender
|
|
203
206
|
|
|
204
|
-
api =
|
|
207
|
+
api = NinjaAIO()
|
|
205
208
|
|
|
206
209
|
|
|
207
210
|
class ExampleSchemaOut(Schema):
|
|
@@ -228,10 +231,7 @@ SumView().add_views_to_route()
|
|
|
228
231
|
```
|
|
229
232
|
|
|
230
233
|
### Relations
|
|
231
|
-
- You can also set ForeignKey and
|
|
232
|
-
|
|
233
|
-
> [!WARNING]
|
|
234
|
-
> Only ForeignKey and OneToOne relations are supported for serialization, ManyToMany relations are not supported yet.
|
|
234
|
+
- You can also set ForeignKey, OneToOne and ManyToMany relations into serialization(reverse relations are supported too). Django ninja aio crud will serialize every of these relation automatically.
|
|
235
235
|
|
|
236
236
|
- Define models:
|
|
237
237
|
|
|
@@ -270,14 +270,14 @@ class Foo(ModelSerializer):
|
|
|
270
270
|
|
|
271
271
|
```Python
|
|
272
272
|
# views.py
|
|
273
|
-
from
|
|
273
|
+
from ninja_aio import NinjaAIO
|
|
274
274
|
from ninja_aio.views import APIViewSet
|
|
275
275
|
from ninja_aio.parsers import ORJSONParser
|
|
276
276
|
from ninja_aio.renders import ORJSONRender
|
|
277
277
|
|
|
278
278
|
from .models import Foo, Bar
|
|
279
279
|
|
|
280
|
-
api =
|
|
280
|
+
api = NinjaAIO()
|
|
281
281
|
|
|
282
282
|
|
|
283
283
|
class FooAPI(APIViewSet):
|
|
@@ -336,14 +336,15 @@ class CustomJWTBearer(AsyncJWTBearer):
|
|
|
336
336
|
|
|
337
337
|
```Python
|
|
338
338
|
# views.py
|
|
339
|
-
from ninja import
|
|
339
|
+
from ninja import Schema
|
|
340
|
+
from ninja_aio import NinjaAIO
|
|
340
341
|
from ninja_aio.views import APIViewSet, APIView
|
|
341
342
|
from ninja_aio.parsers import ORJSONParser
|
|
342
343
|
from ninja_aio.renders import ORJSONRender
|
|
343
344
|
|
|
344
345
|
from .models import Foo
|
|
345
346
|
|
|
346
|
-
api =
|
|
347
|
+
api = NinjaAIO()
|
|
347
348
|
|
|
348
349
|
|
|
349
350
|
class FooAPI(APIViewSet):
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
ninja_aio/__init__.py,sha256=
|
|
1
|
+
ninja_aio/__init__.py,sha256=wVH_cPllWb0Bdyr7atTEbTJxhDdYsDjbn1CVCeB_e60,120
|
|
2
|
+
ninja_aio/api.py,sha256=qEnCOvviJGfg28N9R2XWzykLGOFpJ0JMqe3rm4AYDkM,1564
|
|
2
3
|
ninja_aio/auth.py,sha256=hGgiblvffpHmmakjaxdNT3G0tq39-Bvc5oLNqjn4qd8,1300
|
|
3
4
|
ninja_aio/exceptions.py,sha256=PPNr1CdC7M7Kx1MtiBGuR4hATYQqEuvxCRU6uSG7rgM,543
|
|
4
5
|
ninja_aio/models.py,sha256=xUZ0998bYkWumwZgnVC7P-CLdbfTzFflmJVbusU2UMY,11276
|
|
@@ -6,6 +7,6 @@ ninja_aio/parsers.py,sha256=e_4lGCPV7zs-HTqtdJTc8yQD2KPAn9njbL8nF_Mmgkc,153
|
|
|
6
7
|
ninja_aio/renders.py,sha256=wLQisbIsMJlGYJMO4Ud-qiaVCvz4yxiZ4mYommixAeQ,1453
|
|
7
8
|
ninja_aio/schemas.py,sha256=EgRkfhnzZqwGvdBmqlZixMtMcoD1ZxV_qzJ3fmaAy20,113
|
|
8
9
|
ninja_aio/views.py,sha256=ejn6adCe91YKo0-0bRePbuARHkz8YWMmP54WxQLLqxY,6322
|
|
9
|
-
django_ninja_aio_crud-0.2.
|
|
10
|
-
django_ninja_aio_crud-0.2.
|
|
11
|
-
django_ninja_aio_crud-0.2.
|
|
10
|
+
django_ninja_aio_crud-0.2.1.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
|
|
11
|
+
django_ninja_aio_crud-0.2.1.dist-info/METADATA,sha256=cB1AOW4xZ0DLUpgMAF6AMJVYP48aKy3xQZowVsFWP0g,10135
|
|
12
|
+
django_ninja_aio_crud-0.2.1.dist-info/RECORD,,
|
ninja_aio/__init__.py
CHANGED
ninja_aio/api.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
from typing import Any, Sequence
|
|
2
|
+
|
|
3
|
+
from ninja.router import Router
|
|
4
|
+
from ninja.throttling import BaseThrottle
|
|
5
|
+
from ninja import NinjaAPI
|
|
6
|
+
from ninja.openapi.docs import DocsBase, Swagger
|
|
7
|
+
from ninja.constants import NOT_SET, NOT_SET_TYPE
|
|
8
|
+
|
|
9
|
+
from ninja_aio.parsers import ORJSONParser
|
|
10
|
+
from ninja_aio.renders import ORJSONRenderer
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class NinjaAIO(NinjaAPI):
|
|
14
|
+
def __init__(
|
|
15
|
+
self,
|
|
16
|
+
title: str = "NinjaAPI",
|
|
17
|
+
version: str = "1.0.0",
|
|
18
|
+
description: str = "",
|
|
19
|
+
openapi_url: str | None = "/openapi.json",
|
|
20
|
+
docs: DocsBase = Swagger(),
|
|
21
|
+
docs_url: str | None = "/docs",
|
|
22
|
+
docs_decorator = None,
|
|
23
|
+
servers: list[dict[str, Any]] | None = None,
|
|
24
|
+
urls_namespace: str | None = None,
|
|
25
|
+
csrf: bool = False,
|
|
26
|
+
auth: Sequence[Any]| NOT_SET_TYPE = NOT_SET,
|
|
27
|
+
throttle: BaseThrottle | list[BaseThrottle] | NOT_SET_TYPE = NOT_SET,
|
|
28
|
+
default_router: Router | None = None,
|
|
29
|
+
openapi_extra: dict[str, Any] | None = None
|
|
30
|
+
):
|
|
31
|
+
super().__init__(
|
|
32
|
+
title=title,
|
|
33
|
+
version=version,
|
|
34
|
+
description=description,
|
|
35
|
+
openapi_url=openapi_url,
|
|
36
|
+
docs=docs,
|
|
37
|
+
docs_url=docs_url,
|
|
38
|
+
docs_decorator=docs_decorator,
|
|
39
|
+
servers=servers,
|
|
40
|
+
urls_namespace=urls_namespace,
|
|
41
|
+
csrf=csrf,
|
|
42
|
+
auth=auth,
|
|
43
|
+
throttle=throttle,
|
|
44
|
+
default_router=default_router,
|
|
45
|
+
openapi_extra=openapi_extra,
|
|
46
|
+
renderer=ORJSONRenderer(),
|
|
47
|
+
parser=ORJSONParser(),
|
|
48
|
+
)
|
|
File without changes
|