django-ninja-aio-crud 2.14.0__py3-none-any.whl → 2.15.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.
Potentially problematic release.
This version of django-ninja-aio-crud might be problematic. Click here for more details.
- {django_ninja_aio_crud-2.14.0.dist-info → django_ninja_aio_crud-2.15.0.dist-info}/METADATA +1 -1
- {django_ninja_aio_crud-2.14.0.dist-info → django_ninja_aio_crud-2.15.0.dist-info}/RECORD +6 -6
- ninja_aio/__init__.py +1 -1
- ninja_aio/models/serializers.py +24 -5
- {django_ninja_aio_crud-2.14.0.dist-info → django_ninja_aio_crud-2.15.0.dist-info}/WHEEL +0 -0
- {django_ninja_aio_crud-2.14.0.dist-info → django_ninja_aio_crud-2.15.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
ninja_aio/__init__.py,sha256=
|
|
1
|
+
ninja_aio/__init__.py,sha256=1ZReAODrup4BI5sHOAuanMqhDqfl36W8gVvhBrf5IZ0,120
|
|
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
|
|
@@ -14,7 +14,7 @@ ninja_aio/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
|
|
|
14
14
|
ninja_aio/helpers/api.py,sha256=O2nGvP3VSsG-AReQRn90yDH8vS3kMKh125j-ikwgGoQ,20987
|
|
15
15
|
ninja_aio/helpers/query.py,sha256=Lqv4nrWYr543tC5K-SEcBottLID8cb83aDc26i2Wxj4,5053
|
|
16
16
|
ninja_aio/models/__init__.py,sha256=L3UQnQAlKoI3F7jinadL-Nn55hkPvnSRPYW0JtnbWFo,114
|
|
17
|
-
ninja_aio/models/serializers.py,sha256=
|
|
17
|
+
ninja_aio/models/serializers.py,sha256=tm2ACQO-n877NTYN0YR-6qVZrZQpWgPDh0EeOZo_TWY,42824
|
|
18
18
|
ninja_aio/models/utils.py,sha256=lAXtc3YY7_n4f0jIacX4DSXhUOzMy7y5MsBnInNxtfk,32874
|
|
19
19
|
ninja_aio/schemas/__init__.py,sha256=dHILiYBKMb51lDcyQdiXRw_0nzqM7Lu81UX2hv7kEfo,837
|
|
20
20
|
ninja_aio/schemas/api.py,sha256=dGUpJXR1iAf93QNR4kYj1uqIkTjiMfXultCotY6GtaQ,361
|
|
@@ -24,7 +24,7 @@ ninja_aio/schemas/helpers.py,sha256=h4zQRf21NVLMQbIVH-psAE4FICUBc857EqngblEy7og,
|
|
|
24
24
|
ninja_aio/views/__init__.py,sha256=DEzjWA6y3WF0V10nNF8eEurLNEodgxKzyFd09AqVp3s,148
|
|
25
25
|
ninja_aio/views/api.py,sha256=AAqkj0xT8J3PmJvsbluZ33cfrmrXJHiV9ARe2BqnfQ8,22492
|
|
26
26
|
ninja_aio/views/mixins.py,sha256=Zl6J8gbVagwT85bzDuKyJTk3iFxxFgX0YgYkjiUxZGg,17040
|
|
27
|
-
django_ninja_aio_crud-2.
|
|
28
|
-
django_ninja_aio_crud-2.
|
|
29
|
-
django_ninja_aio_crud-2.
|
|
30
|
-
django_ninja_aio_crud-2.
|
|
27
|
+
django_ninja_aio_crud-2.15.0.dist-info/licenses/LICENSE,sha256=yrDAYcm0gRp_Qyzo3GQa4BjYjWRkAhGC8QRva__RYq0,1073
|
|
28
|
+
django_ninja_aio_crud-2.15.0.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
|
29
|
+
django_ninja_aio_crud-2.15.0.dist-info/METADATA,sha256=m89g4FLCQgQvwCkSoJLxzsUwCuf4ESwyqKJLX31qKAo,9964
|
|
30
|
+
django_ninja_aio_crud-2.15.0.dist-info/RECORD,,
|
ninja_aio/__init__.py
CHANGED
ninja_aio/models/serializers.py
CHANGED
|
@@ -46,8 +46,23 @@ def _extract_pk(v: Any) -> Any:
|
|
|
46
46
|
return v
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
class PkFromModel:
|
|
50
|
+
"""Subscriptable type for extracting PK from model instances during serialization.
|
|
51
|
+
|
|
52
|
+
Usage:
|
|
53
|
+
PkFromModel[int] -> for integer PKs
|
|
54
|
+
PkFromModel[str] -> for string PKs
|
|
55
|
+
PkFromModel[UUID] -> for UUID PKs
|
|
56
|
+
PkFromModel -> defaults to int (backwards compatible)
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
_default = Annotated[int, BeforeValidator(_extract_pk)]
|
|
60
|
+
|
|
61
|
+
def __class_getitem__(cls, pk_type: type) -> type:
|
|
62
|
+
return Annotated[pk_type, BeforeValidator(_extract_pk)]
|
|
63
|
+
|
|
64
|
+
def __new__(cls):
|
|
65
|
+
return cls._default
|
|
51
66
|
|
|
52
67
|
|
|
53
68
|
class BaseSerializer:
|
|
@@ -415,12 +430,14 @@ class BaseSerializer:
|
|
|
415
430
|
|
|
416
431
|
# Handle relations_as_id for reverse relations
|
|
417
432
|
if field_name in relations_as_id:
|
|
433
|
+
from ninja_aio.models.utils import ModelUtil
|
|
434
|
+
pk_field_type = ModelUtil(rel_model).pk_field_type
|
|
418
435
|
if many:
|
|
419
436
|
# For many relations, use PkFromModel to extract PKs from model instances
|
|
420
|
-
return (field_name, list[PkFromModel], Field(default_factory=list))
|
|
437
|
+
return (field_name, list[PkFromModel[pk_field_type]], Field(default_factory=list))
|
|
421
438
|
else:
|
|
422
439
|
# For single reverse relations (ReverseOneToOne), extract pk
|
|
423
|
-
return (field_name, PkFromModel | None, None)
|
|
440
|
+
return (field_name, PkFromModel[pk_field_type] | None, None)
|
|
424
441
|
|
|
425
442
|
schema = cls._resolve_relation_schema(field_name, rel_model)
|
|
426
443
|
if not schema:
|
|
@@ -455,8 +472,10 @@ class BaseSerializer:
|
|
|
455
472
|
|
|
456
473
|
# Handle relations_as_id: serialize as the raw FK ID
|
|
457
474
|
if field_name in relations_as_id:
|
|
475
|
+
from ninja_aio.models.utils import ModelUtil
|
|
476
|
+
pk_field_type = ModelUtil(rel_model).pk_field_type
|
|
458
477
|
# Use PkFromModel to extract pk from the related instance during serialization
|
|
459
|
-
return (field_name, PkFromModel | None, None)
|
|
478
|
+
return (field_name, PkFromModel[pk_field_type] | None, None)
|
|
460
479
|
|
|
461
480
|
# Special case: ModelSerializer with no readable fields should be skipped entirely
|
|
462
481
|
if isinstance(rel_model, ModelSerializerMeta):
|
|
File without changes
|
{django_ninja_aio_crud-2.14.0.dist-info → django_ninja_aio_crud-2.15.0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|