django-ninja-aio-crud 0.7.5__tar.gz → 0.7.7__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: django-ninja-aio-crud
3
- Version: 0.7.5
3
+ Version: 0.7.7
4
4
  Summary: Django Ninja AIO CRUD - Rest Framework
5
5
  Author: Giuseppe Casillo
6
6
  Requires-Python: >=3.10
@@ -1,6 +1,6 @@
1
1
  """Django Ninja AIO CRUD - Rest Framework"""
2
2
 
3
- __version__ = "0.7.5"
3
+ __version__ = "0.7.7"
4
4
 
5
5
  from .api import NinjaAIO
6
6
 
@@ -142,7 +142,7 @@ class ModelUtil:
142
142
  ):
143
143
  rel_util = ModelUtil(field_obj.related_model)
144
144
  rel: ModelSerializer = await rel_util.get_object(
145
- request, list(v.values())[0], with_qs_request=False
145
+ request, list(v.values())[0]
146
146
  )
147
147
  if isinstance(field_obj, models.ForeignKey):
148
148
  for rel_k, rel_v in v.items():
@@ -174,7 +174,9 @@ class ModelUtil:
174
174
  ):
175
175
  if obj_schema is None:
176
176
  raise SerializeError({"obj_schema": "must be provided"}, 400)
177
- return await self.parse_output_data(request, obj_schema.from_orm(obj))
177
+ return await self.parse_output_data(
178
+ request, await sync_to_async(obj_schema.from_orm)(obj)
179
+ )
178
180
 
179
181
  async def update_s(
180
182
  self, request: HttpRequest, data: Schema, pk: int | str, obj_schema: Schema
@@ -353,7 +355,10 @@ class ModelSerializer(models.Model, metaclass=ModelSerializerMeta):
353
355
  @classmethod
354
356
  def get_related_schema_data(cls):
355
357
  fields = cls.get_fields("read")
356
- custom_f = {name: (value, default) for name, value, default in cls.get_custom_fields("read")}
358
+ custom_f = {
359
+ name: (value, default)
360
+ for name, value, default in cls.get_custom_fields("read")
361
+ }
357
362
  _related_fields = []
358
363
  for f in fields + list(custom_f.keys()):
359
364
  field_obj = getattr(cls, f)
@@ -372,8 +377,9 @@ class ModelSerializer(models.Model, metaclass=ModelSerializerMeta):
372
377
  if not _related_fields:
373
378
  return None, None
374
379
 
375
-
376
- custom_related_fields = [(f, *custom_f[f]) for f in _related_fields if f in custom_f]
380
+ custom_related_fields = [
381
+ (f, *custom_f[f]) for f in _related_fields if f in custom_f
382
+ ]
377
383
  related_fields = [f for f in _related_fields if f not in custom_f]
378
384
  return related_fields, custom_related_fields
379
385