django-ninja-aio-crud 1.0.2__py3-none-any.whl → 1.0.4__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-1.0.2.dist-info → django_ninja_aio_crud-1.0.4.dist-info}/METADATA +1 -1
- {django_ninja_aio_crud-1.0.2.dist-info → django_ninja_aio_crud-1.0.4.dist-info}/RECORD +6 -6
- ninja_aio/__init__.py +1 -1
- ninja_aio/models.py +13 -15
- {django_ninja_aio_crud-1.0.2.dist-info → django_ninja_aio_crud-1.0.4.dist-info}/WHEEL +0 -0
- {django_ninja_aio_crud-1.0.2.dist-info → django_ninja_aio_crud-1.0.4.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
ninja_aio/__init__.py,sha256=
|
|
1
|
+
ninja_aio/__init__.py,sha256=95P7L4A3Zc-I6E6A0tZVldTPW4UkWGGFmjkg8B9dFbI,119
|
|
2
2
|
ninja_aio/api.py,sha256=Fe6l3YCy7MW5TY4-Lbl80CFuK2NT2Y7tHfmqPk6Mqak,1735
|
|
3
3
|
ninja_aio/auth.py,sha256=zUwruKcz7MXuOnWp5k1CCSwEc8s2Lyqqk7Qm9kPbJ3o,5149
|
|
4
4
|
ninja_aio/decorators.py,sha256=LsvHbMxmw_So8NV0ey5NRRvSbfYkOZLeLQ4Fix7rQAY,5519
|
|
5
5
|
ninja_aio/exceptions.py,sha256=1-iRbrloIyi0CR6Tcrn5YR4_LloA7PPohKIBaxXJ0-8,2596
|
|
6
|
-
ninja_aio/models.py,sha256=
|
|
6
|
+
ninja_aio/models.py,sha256=fsFYjKFZb8MDpE1g3Nte-Dot4x7ofmuxIDi8qtkWu0o,35422
|
|
7
7
|
ninja_aio/parsers.py,sha256=e_4lGCPV7zs-HTqtdJTc8yQD2KPAn9njbL8nF_Mmgkc,153
|
|
8
8
|
ninja_aio/renders.py,sha256=5TdSQI8e4x3Gb2tAw1AaxrbU-asVjf2chWMr8x2Tt80,1485
|
|
9
9
|
ninja_aio/schemas.py,sha256=sYxhovFq6nE_Gdx_yl1ufcuHBAXxpsnBmNytyTSqFLI,2449
|
|
@@ -11,7 +11,7 @@ ninja_aio/types.py,sha256=TJSGlA7bt4g9fvPhJ7gzH5tKbLagPmZUzfgttEOp4xs,468
|
|
|
11
11
|
ninja_aio/views.py,sha256=31pyOzABHwO1jcIVJRHXVrpMu9__FHmdX2vEhX6XrPs,15890
|
|
12
12
|
ninja_aio/helpers/__init__.py,sha256=E45h2prtpCudx_bSKkIDMNK9oxrHPDJrweXWCuLxUOs,59
|
|
13
13
|
ninja_aio/helpers/api.py,sha256=VW5C4hQl2flYhGPgVJ2ZkFK1tGMdNOaxVWJfZfLd7OY,17171
|
|
14
|
-
django_ninja_aio_crud-1.0.
|
|
15
|
-
django_ninja_aio_crud-1.0.
|
|
16
|
-
django_ninja_aio_crud-1.0.
|
|
17
|
-
django_ninja_aio_crud-1.0.
|
|
14
|
+
django_ninja_aio_crud-1.0.4.dist-info/licenses/LICENSE,sha256=yrDAYcm0gRp_Qyzo3GQa4BjYjWRkAhGC8QRva__RYq0,1073
|
|
15
|
+
django_ninja_aio_crud-1.0.4.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
|
16
|
+
django_ninja_aio_crud-1.0.4.dist-info/METADATA,sha256=k6Uj8u75lr49s9FC6yGodKODbkHREdrIefQ2CtvqMW8,8540
|
|
17
|
+
django_ninja_aio_crud-1.0.4.dist-info/RECORD,,
|
ninja_aio/__init__.py
CHANGED
ninja_aio/models.py
CHANGED
|
@@ -284,14 +284,14 @@ class ModelUtil:
|
|
|
284
284
|
rel = await rel_util.get_object(request, v, with_qs_request=False)
|
|
285
285
|
payload[k] = rel
|
|
286
286
|
|
|
287
|
-
def _extract_field_obj(self, field_name: str):
|
|
287
|
+
async def _extract_field_obj(self, field_name: str):
|
|
288
288
|
"""
|
|
289
289
|
Return the underlying Django Field (if any) for a given attribute name.
|
|
290
290
|
"""
|
|
291
|
-
descriptor =
|
|
291
|
+
descriptor = await agetattr(self.model, field_name, None)
|
|
292
292
|
if descriptor is None:
|
|
293
293
|
return None
|
|
294
|
-
return
|
|
294
|
+
return await agetattr(descriptor, "field", None) or await agetattr(
|
|
295
295
|
descriptor, "related", None
|
|
296
296
|
)
|
|
297
297
|
|
|
@@ -313,18 +313,20 @@ class ModelUtil:
|
|
|
313
313
|
rel_pk = nested_dict.get(rel_util.model_pk_name)
|
|
314
314
|
return await rel_util.get_object(request, rel_pk)
|
|
315
315
|
|
|
316
|
-
def _rewrite_nested_foreign_keys(self, rel_obj, nested_dict: dict):
|
|
316
|
+
async def _rewrite_nested_foreign_keys(self, rel_obj, nested_dict: dict):
|
|
317
317
|
"""
|
|
318
318
|
Rewrite foreign key keys inside a nested dict from <key> to <key>_id.
|
|
319
319
|
"""
|
|
320
320
|
keys_to_rewrite: list[str] = []
|
|
321
|
+
new_nested = nested_dict
|
|
321
322
|
for rel_k in nested_dict.keys():
|
|
322
|
-
attr =
|
|
323
|
-
|
|
324
|
-
if isinstance(fk_field, models.ForeignKey):
|
|
323
|
+
attr = await agetattr(rel_obj, rel_k)
|
|
324
|
+
if isinstance(attr, models.ForeignKey):
|
|
325
325
|
keys_to_rewrite.append(rel_k)
|
|
326
|
-
|
|
327
|
-
|
|
326
|
+
for old_k in keys_to_rewrite:
|
|
327
|
+
new_nested[f"{old_k}_id"] = new_nested.pop(old_k)
|
|
328
|
+
return new_nested
|
|
329
|
+
|
|
328
330
|
|
|
329
331
|
async def parse_input_data(self, request: HttpRequest, data: Schema):
|
|
330
332
|
"""
|
|
@@ -416,17 +418,13 @@ class ModelUtil:
|
|
|
416
418
|
payload = data.model_dump(mode="json")
|
|
417
419
|
|
|
418
420
|
for k, v in payload.items():
|
|
419
|
-
field_obj = self._extract_field_obj(k)
|
|
421
|
+
field_obj = await self._extract_field_obj(k)
|
|
420
422
|
if not self._should_process_nested(v, field_obj):
|
|
421
423
|
continue
|
|
422
|
-
|
|
423
424
|
rel_instance = await self._fetch_related_instance(request, field_obj, v)
|
|
424
|
-
|
|
425
425
|
if isinstance(field_obj, models.ForeignKey):
|
|
426
|
-
self._rewrite_nested_foreign_keys(rel_instance, v)
|
|
427
|
-
|
|
426
|
+
v = await self._rewrite_nested_foreign_keys(rel_instance, v)
|
|
428
427
|
payload[k] = rel_instance
|
|
429
|
-
|
|
430
428
|
return payload
|
|
431
429
|
|
|
432
430
|
async def create_s(self, request: HttpRequest, data: Schema, obj_schema: Schema):
|
|
File without changes
|
{django_ninja_aio_crud-1.0.2.dist-info → django_ninja_aio_crud-1.0.4.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|