django-ninja-aio-crud 2.3.2__py3-none-any.whl → 2.5.0__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-2.3.2.dist-info → django_ninja_aio_crud-2.5.0.dist-info}/METADATA +31 -6
- {django_ninja_aio_crud-2.3.2.dist-info → django_ninja_aio_crud-2.5.0.dist-info}/RECORD +10 -8
- ninja_aio/__init__.py +1 -1
- ninja_aio/helpers/query.py +2 -2
- ninja_aio/models/__init__.py +4 -0
- ninja_aio/models/serializers.py +888 -0
- ninja_aio/{models.py → models/utils.py} +75 -670
- ninja_aio/views/api.py +44 -19
- {django_ninja_aio_crud-2.3.2.dist-info → django_ninja_aio_crud-2.5.0.dist-info}/WHEEL +0 -0
- {django_ninja_aio_crud-2.3.2.dist-info → django_ninja_aio_crud-2.5.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: django-ninja-aio-crud
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.5.0
|
|
4
4
|
Summary: Django Ninja AIO CRUD - Rest Framework
|
|
5
5
|
Author: Giuseppe Casillo
|
|
6
6
|
Requires-Python: >=3.10, <3.15
|
|
@@ -48,6 +48,7 @@ Provides-Extra: test
|
|
|
48
48
|
|
|
49
49
|
## ✨ Features
|
|
50
50
|
|
|
51
|
+
- Serializer (Meta-driven) first-class: dynamic schemas for existing Django models without inheriting ModelSerializer
|
|
51
52
|
- Async CRUD ViewSets (create, list, retrieve, update, delete)
|
|
52
53
|
- Automatic Pydantic schemas from `ModelSerializer` (read/create/update)
|
|
53
54
|
- Dynamic query params (runtime schema via `pydantic.create_model`)
|
|
@@ -61,17 +62,35 @@ Provides-Extra: test
|
|
|
61
62
|
|
|
62
63
|
---
|
|
63
64
|
|
|
64
|
-
##
|
|
65
|
+
## 🚀 Quick Start (Serializer)
|
|
65
66
|
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
If you already have Django models, start with the Meta-driven Serializer for instant CRUD without changing model base classes.
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from ninja_aio.models import serializers
|
|
71
|
+
from ninja_aio.views import APIViewSet
|
|
72
|
+
from ninja_aio import NinjaAIO
|
|
73
|
+
from . import models
|
|
74
|
+
|
|
75
|
+
class BookSerializer(serializers.Serializer):
|
|
76
|
+
class Meta:
|
|
77
|
+
model = models.Book
|
|
78
|
+
schema_in = serializers.SchemaModelConfig(fields=["title", "published"])
|
|
79
|
+
schema_out = serializers.SchemaModelConfig(fields=["id", "title", "published"])
|
|
80
|
+
schema_update = serializers.SchemaModelConfig(optionals=[("title", str), ("published", bool)])
|
|
81
|
+
|
|
82
|
+
api = NinjaAIO()
|
|
83
|
+
|
|
84
|
+
@api.viewset(models.Book)
|
|
85
|
+
class BookViewSet(APIViewSet):
|
|
86
|
+
serializer_class = BookSerializer
|
|
68
87
|
```
|
|
69
88
|
|
|
70
|
-
|
|
89
|
+
Visit `/docs` → CRUD endpoints ready.
|
|
71
90
|
|
|
72
91
|
---
|
|
73
92
|
|
|
74
|
-
## 🚀 Quick Start
|
|
93
|
+
## 🚀 Quick Start (ModelSerializer)
|
|
75
94
|
|
|
76
95
|
models.py
|
|
77
96
|
|
|
@@ -262,6 +281,12 @@ class BookViewSet(APIViewSet):
|
|
|
262
281
|
|
|
263
282
|
---
|
|
264
283
|
|
|
284
|
+
## Meta-driven Serializer (for vanilla Django models)
|
|
285
|
+
|
|
286
|
+
Moved above as the primary quick start.
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
265
290
|
## 🛠 Project Structure & Docs
|
|
266
291
|
|
|
267
292
|
Documentation (MkDocs + Material):
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
ninja_aio/__init__.py,sha256
|
|
1
|
+
ninja_aio/__init__.py,sha256=LBFfoQaFXisUD0DcYa1xZV-zyiAJqx_3QAY-hyxB6OA,119
|
|
2
2
|
ninja_aio/api.py,sha256=tuC7vdvn7s1GkCnSFy9Kn1zv0glZfYptRQVvo8ZRtGQ,2429
|
|
3
3
|
ninja_aio/auth.py,sha256=4sWdFPjKiQgUL1d_CSGDblVjnY5ptP6LQha6XXdluJA,9157
|
|
4
4
|
ninja_aio/exceptions.py,sha256=_3xFqfFCOfrrMhSA0xbMqgXy8R0UQjhXaExrFvaDAjY,3891
|
|
5
|
-
ninja_aio/models.py,sha256=aJlo5a64O4o-fB8QESLMUJpoA5kcjRJxPBiAIMxg46k,47652
|
|
6
5
|
ninja_aio/parsers.py,sha256=e_4lGCPV7zs-HTqtdJTc8yQD2KPAn9njbL8nF_Mmgkc,153
|
|
7
6
|
ninja_aio/renders.py,sha256=89g46NWUT8nmDG-rG0nxUYbAQWhuXcYKrPh7e1r_Fc4,1735
|
|
8
7
|
ninja_aio/types.py,sha256=nFqWEopm7eoEaHRzbi6EyA9WZ5Cneyd602ilFKypeQI,577
|
|
@@ -13,15 +12,18 @@ ninja_aio/factory/__init__.py,sha256=IdH2z1ZZpv_IqonaDfVo7IsMzkgop6lHqz42RphUYBU
|
|
|
13
12
|
ninja_aio/factory/operations.py,sha256=OgWGqq4WJ4arSQrH9FGAby9kx-HTdS7MOITxHdYMk18,12051
|
|
14
13
|
ninja_aio/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
14
|
ninja_aio/helpers/api.py,sha256=YMzuZ4-ZpUrJBQIabE26gb_GYwsH2rVosWRE95YfdPQ,20775
|
|
16
|
-
ninja_aio/helpers/query.py,sha256=
|
|
15
|
+
ninja_aio/helpers/query.py,sha256=lzaH-htswoJVRT-W736HGMkpMba1VmN98TBLv5cZx9Q,4549
|
|
16
|
+
ninja_aio/models/__init__.py,sha256=L3UQnQAlKoI3F7jinadL-Nn55hkPvnSRPYW0JtnbWFo,114
|
|
17
|
+
ninja_aio/models/serializers.py,sha256=-6NsyTJBdUQl3fkAusC7Kx_2keMRV7CNI9yAlH_fQns,29340
|
|
18
|
+
ninja_aio/models/utils.py,sha256=P-YfbVyzUfxm_s1BrgSd6Zs0HIGdZ79PU1qM0Ud9-Xs,30492
|
|
17
19
|
ninja_aio/schemas/__init__.py,sha256=iLBwHg0pmL9k_UkIui5Q8QIl_gO4fgxSv2JHxDzqnSI,549
|
|
18
20
|
ninja_aio/schemas/api.py,sha256=-VwXhBRhmMsZLIAmWJ-P7tB5klxXS75eukjabeKKYsc,360
|
|
19
21
|
ninja_aio/schemas/generics.py,sha256=frjJsKJMAdM_NdNKv-9ddZNGxYy5PNzjIRGtuycgr-w,112
|
|
20
22
|
ninja_aio/schemas/helpers.py,sha256=W6IeHi5Tmbjh3FXwDYqjqlLBTVj5uTYq3_JVkNUWayo,7355
|
|
21
23
|
ninja_aio/views/__init__.py,sha256=DEzjWA6y3WF0V10nNF8eEurLNEodgxKzyFd09AqVp3s,148
|
|
22
|
-
ninja_aio/views/api.py,sha256=
|
|
24
|
+
ninja_aio/views/api.py,sha256=xdzxM1XOPTZmGrRxlIz1QH4UKgxRfg9ls-geatTJrXI,21179
|
|
23
25
|
ninja_aio/views/mixins.py,sha256=Jh6BG8Cs823nurVlODlzCquTxKrLH7Pmo5udPqUGZek,11378
|
|
24
|
-
django_ninja_aio_crud-2.
|
|
25
|
-
django_ninja_aio_crud-2.
|
|
26
|
-
django_ninja_aio_crud-2.
|
|
27
|
-
django_ninja_aio_crud-2.
|
|
26
|
+
django_ninja_aio_crud-2.5.0.dist-info/licenses/LICENSE,sha256=yrDAYcm0gRp_Qyzo3GQa4BjYjWRkAhGC8QRva__RYq0,1073
|
|
27
|
+
django_ninja_aio_crud-2.5.0.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
|
28
|
+
django_ninja_aio_crud-2.5.0.dist-info/METADATA,sha256=Gyk2TCPm3oQaT9YsZrXC7btzZzmDmntKyk_wz0M6Hfg,9963
|
|
29
|
+
django_ninja_aio_crud-2.5.0.dist-info/RECORD,,
|
ninja_aio/__init__.py
CHANGED
ninja_aio/helpers/query.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from ninja_aio.
|
|
1
|
+
from ninja_aio.models.serializers import Serializer, ModelSerializer
|
|
2
2
|
from ninja_aio.schemas.helpers import (
|
|
3
3
|
ModelQuerySetSchema,
|
|
4
4
|
QueryUtilBaseScopesSchema,
|
|
@@ -52,7 +52,7 @@ class QueryUtil:
|
|
|
52
52
|
|
|
53
53
|
SCOPES: QueryUtilBaseScopesSchema
|
|
54
54
|
|
|
55
|
-
def __init__(self, model:
|
|
55
|
+
def __init__(self, model: ModelSerializer | Serializer):
|
|
56
56
|
"""Initialize QueryUtil, resolving base and extra scope configurations for a model."""
|
|
57
57
|
self.model = model
|
|
58
58
|
self._configuration = getattr(self.model, "QuerySet", None)
|