django-ninja-aio-crud 2.11.2__py3-none-any.whl → 2.12.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.

Potentially problematic release.


This version of django-ninja-aio-crud might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: django-ninja-aio-crud
3
- Version: 2.11.2
3
+ Version: 2.12.1
4
4
  Summary: Django Ninja AIO CRUD - Rest Framework
5
5
  Author: Giuseppe Casillo
6
6
  Requires-Python: >=3.10, <3.15
@@ -1,4 +1,4 @@
1
- ninja_aio/__init__.py,sha256=zel16nCqeM9xP7okxwBDuXqmTbqiVNj6S9eNjSG-EP8,120
1
+ ninja_aio/__init__.py,sha256=VnXks7HBLJ2tZT6r9e4AVSFvISb8EEx7v4IznmY0N84,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
@@ -12,9 +12,9 @@ ninja_aio/factory/__init__.py,sha256=IdH2z1ZZpv_IqonaDfVo7IsMzkgop6lHqz42RphUYBU
12
12
  ninja_aio/factory/operations.py,sha256=OgWGqq4WJ4arSQrH9FGAby9kx-HTdS7MOITxHdYMk18,12051
13
13
  ninja_aio/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  ninja_aio/helpers/api.py,sha256=2beyexep-ehgaA_1bV5Yuh3zRDVcRCMkrW94nmfDWEA,20819
15
- ninja_aio/helpers/query.py,sha256=NMGkS_v-ZVYKNtf1XohEUzfwca52Eq5FTcQ5lehHjus,4682
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=I7pUz_vl0FElaVsrGaogT_Lj9T4uaNG7UDMGf5VMwW4,38468
17
+ ninja_aio/models/serializers.py,sha256=uLy0FlVWw7aqr4K0UDk4In-QFGjYLL9RfPX103ApV10,38603
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=Vti5BfHWpxaJXj_ixZBJb34VRwhHODrlVjRlIuHh_ug,
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.11.2.dist-info/licenses/LICENSE,sha256=yrDAYcm0gRp_Qyzo3GQa4BjYjWRkAhGC8QRva__RYq0,1073
28
- django_ninja_aio_crud-2.11.2.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
29
- django_ninja_aio_crud-2.11.2.dist-info/METADATA,sha256=j7tcR1Q6YaT1bMnzs4XFx4f-9029BdraE77ZhOZKMy4,9964
30
- django_ninja_aio_crud-2.11.2.dist-info/RECORD,,
27
+ django_ninja_aio_crud-2.12.1.dist-info/licenses/LICENSE,sha256=yrDAYcm0gRp_Qyzo3GQa4BjYjWRkAhGC8QRva__RYq0,1073
28
+ django_ninja_aio_crud-2.12.1.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
29
+ django_ninja_aio_crud-2.12.1.dist-info/METADATA,sha256=O5VqJpldXVWYmLHEiW8ede9NyGygvPJ6DGsmz67mWe0,9964
30
+ django_ninja_aio_crud-2.12.1.dist-info/RECORD,,
ninja_aio/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  """Django Ninja AIO CRUD - Rest Framework"""
2
2
 
3
- __version__ = "2.11.2"
3
+ __version__ = "2.12.1"
4
4
 
5
5
  from .api import NinjaAIO
6
6
 
@@ -78,6 +78,11 @@ class QueryUtil:
78
78
  self.detail_config: ModelQuerySetSchema = self._configs.get(
79
79
  self.SCOPES.DETAIL, ModelQuerySetSchema()
80
80
  )
81
+ # Fallback detail config to read config if not explicitly set
82
+ if not self.detail_config.select_related:
83
+ self.detail_config.select_related = self.read_config.select_related.copy()
84
+ if not self.detail_config.prefetch_related:
85
+ self.detail_config.prefetch_related = self.read_config.prefetch_related.copy()
81
86
 
82
87
  def _get_config(self, conf_name: str) -> ModelQuerySetSchema:
83
88
  """Helper method to retrieve configuration attributes."""
@@ -103,7 +108,7 @@ class QueryUtil:
103
108
  raise ValueError(
104
109
  f"Invalid scope '{scope}' for QueryUtil. Supported scopes: {valid_scopes}"
105
110
  )
106
- config = self._configs.get(scope, ModelQuerySetSchema())
111
+ config: ModelQuerySetSchema = self._configs.get(scope, ModelQuerySetSchema())
107
112
  if config.select_related:
108
113
  queryset = queryset.select_related(*config.select_related)
109
114
  if config.prefetch_related:
@@ -333,11 +333,7 @@ class BaseSerializer:
333
333
  @classmethod
334
334
  def get_fields(cls, s_type: S_TYPES):
335
335
  """Return explicit declared fields for the serializer type."""
336
- fields = cls._get_fields(s_type, "fields")
337
- # Detail schema falls back to read fields if none declared
338
- if not fields and s_type == "detail":
339
- return cls._get_fields("read", "fields")
340
- return fields
336
+ return cls._get_fields(s_type, "fields")
341
337
 
342
338
  @classmethod
343
339
  def is_custom(cls, field: str) -> bool:
@@ -428,8 +424,9 @@ class BaseSerializer:
428
424
  @classmethod
429
425
  def _warn_missing_relation_serializer(cls, field_name: str, model) -> None:
430
426
  """Emit warning for reverse relations without explicit serializer mapping."""
431
- if not isinstance(model, ModelSerializerMeta) and not getattr(
432
- settings, "NINJA_AIO_TESTING", False
427
+ if not isinstance(model, ModelSerializerMeta) and (
428
+ not getattr(settings, "NINJA_AIO_TESTING", False)
429
+ or getattr(settings, "NINJA_AIO_RAISE_SERIALIZATION_WARNINGS", False)
433
430
  ):
434
431
  warnings.warn(
435
432
  f"{cls.__name__}: reverse relation '{field_name}' is listed in read fields "
@@ -781,7 +778,10 @@ class ModelSerializer(models.Model, BaseSerializer, metaclass=ModelSerializerMet
781
778
  if not config_class_name:
782
779
  return []
783
780
  config_class = getattr(cls, config_class_name)
784
- return getattr(config_class, f_type, [])
781
+ fields = getattr(config_class, f_type, [])
782
+ if not fields and s_type == "detail":
783
+ fields = getattr(cls.ReadSerializer, f_type, [])
784
+ return fields
785
785
 
786
786
  @classmethod
787
787
  def _get_model(cls) -> "ModelSerializer":
@@ -1006,7 +1006,10 @@ class Serializer(BaseSerializer, metaclass=SerializerMeta):
1006
1006
  return []
1007
1007
  schema = cls._get_schema_meta(schema_key)
1008
1008
  if not schema:
1009
- return []
1009
+ if s_type == "detail":
1010
+ schema = cls._get_schema_meta("out")
1011
+ else:
1012
+ return []
1010
1013
  return getattr(schema, f_type, []) or []
1011
1014
 
1012
1015
  @classmethod