drf-react-by-schema 0.29.2__tar.gz → 0.29.3__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.
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/PKG-INFO +14 -5
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/README.rst +13 -4
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/autocomplete_serializers.py +2 -1
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/autocomplete_viewsets.py +9 -5
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/checks.py +5 -1
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/serializers.py +2 -1
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/tests.py +2 -2
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/urls.py +4 -5
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/utils.py +37 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/viewsets.py +12 -4
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema.egg-info/PKG-INFO +14 -5
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/setup.cfg +1 -1
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/LICENSE +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/MANIFEST.in +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/__init__.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/admin.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/apps.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/auth.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/date_utils.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/fields/__init__.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/fields/array.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/fields/boolean.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/fields/date.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/fields/file.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/fields/geometry.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/fields/number.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/fields/relational.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/fields/serializers.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/fields/text.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/filters.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/management/__init__.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/management/commands/__init__.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/management/commands/sync_react.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/metadata.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/migrations/0001_initial.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/migrations/__init__.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/mixins.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/models.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/pagination.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/patches/__init__.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/patches/drf_serializers.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/renderers.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/schema_bundle.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/typescript_generator.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/utils_cache.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/views.py +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema.egg-info/SOURCES.txt +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema.egg-info/dependency_links.txt +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema.egg-info/requires.txt +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema.egg-info/top_level.txt +0 -0
- {drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: drf_react_by_schema
|
|
3
|
-
Version: 0.29.
|
|
3
|
+
Version: 0.29.3
|
|
4
4
|
Summary: A Django app to easily integrate with React from models.
|
|
5
5
|
Home-page: https://gitlab.com/eita/drf-react-by-schema/drf-react-by-schema-django
|
|
6
6
|
Author: Cooperativa EITA
|
|
@@ -164,7 +164,10 @@ Installation and quick start
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
4. Configure ``DRF_REACT_BY_SCHEMA``. The only required entry is the list of apps
|
|
167
|
-
whose models should get an endpoint (default ``['main']``)
|
|
167
|
+
whose models should get an endpoint (default ``['main']``). Each entry is an app
|
|
168
|
+
label (``'main'``) or a dotted module path (``'my_package.produtos'``) — the
|
|
169
|
+
dotted form lets a distribution ship its Django app nested inside its own
|
|
170
|
+
package instead of taking a top-level name:
|
|
168
171
|
|
|
169
172
|
.. code-block:: python
|
|
170
173
|
|
|
@@ -222,9 +225,15 @@ Configuration reference
|
|
|
222
225
|
``DRF_REACT_BY_SCHEMA`` is the only settings block the package reads (via
|
|
223
226
|
``settings.get("DRF_REACT_BY_SCHEMA", {})``):
|
|
224
227
|
|
|
225
|
-
* ``APPS`` (default ``["main"]``) — the
|
|
226
|
-
serializers, viewsets and routes.
|
|
227
|
-
``
|
|
228
|
+
* ``APPS`` (default ``["main"]``) — the apps whose models get generated
|
|
229
|
+
serializers, viewsets and routes. Each entry is an app label (``"main"``) or a
|
|
230
|
+
dotted module path (``"my_package.produtos"``); the dotted form lets a
|
|
231
|
+
distribution ship its Django app nested inside its own package instead of
|
|
232
|
+
occupying a top-level name. ``utils.resolve_apps()`` normalizes an entry to
|
|
233
|
+
``(label, module_path)`` — the label keys ``apps.all_models`` and matches
|
|
234
|
+
``Model._meta.app_label``, while the module path is imported as
|
|
235
|
+
``<module>.viewsets`` / ``<module>.serializers``. Consumed by ``urls.py``,
|
|
236
|
+
``viewsets.py``, ``serializers.py``, the autocomplete modules and ``sync_react``.
|
|
228
237
|
* ``REACT_APP_DIR`` (default ``"frontend"``) — where ``sync_react`` writes
|
|
229
238
|
``src/drfReactBySchema/``, resolved as ``os.path.join(settings.BASE_DIR, REACT_APP_DIR)``.
|
|
230
239
|
* ``PERMISSIONS`` — the permission source for the generated viewsets (and for
|
|
@@ -131,7 +131,10 @@ Installation and quick start
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
4. Configure ``DRF_REACT_BY_SCHEMA``. The only required entry is the list of apps
|
|
134
|
-
whose models should get an endpoint (default ``['main']``)
|
|
134
|
+
whose models should get an endpoint (default ``['main']``). Each entry is an app
|
|
135
|
+
label (``'main'``) or a dotted module path (``'my_package.produtos'``) — the
|
|
136
|
+
dotted form lets a distribution ship its Django app nested inside its own
|
|
137
|
+
package instead of taking a top-level name:
|
|
135
138
|
|
|
136
139
|
.. code-block:: python
|
|
137
140
|
|
|
@@ -189,9 +192,15 @@ Configuration reference
|
|
|
189
192
|
``DRF_REACT_BY_SCHEMA`` is the only settings block the package reads (via
|
|
190
193
|
``settings.get("DRF_REACT_BY_SCHEMA", {})``):
|
|
191
194
|
|
|
192
|
-
* ``APPS`` (default ``["main"]``) — the
|
|
193
|
-
serializers, viewsets and routes.
|
|
194
|
-
``
|
|
195
|
+
* ``APPS`` (default ``["main"]``) — the apps whose models get generated
|
|
196
|
+
serializers, viewsets and routes. Each entry is an app label (``"main"``) or a
|
|
197
|
+
dotted module path (``"my_package.produtos"``); the dotted form lets a
|
|
198
|
+
distribution ship its Django app nested inside its own package instead of
|
|
199
|
+
occupying a top-level name. ``utils.resolve_apps()`` normalizes an entry to
|
|
200
|
+
``(label, module_path)`` — the label keys ``apps.all_models`` and matches
|
|
201
|
+
``Model._meta.app_label``, while the module path is imported as
|
|
202
|
+
``<module>.viewsets`` / ``<module>.serializers``. Consumed by ``urls.py``,
|
|
203
|
+
``viewsets.py``, ``serializers.py``, the autocomplete modules and ``sync_react``.
|
|
195
204
|
* ``REACT_APP_DIR`` (default ``"frontend"``) — where ``sync_react`` writes
|
|
196
205
|
``src/drfReactBySchema/``, resolved as ``os.path.join(settings.BASE_DIR, REACT_APP_DIR)``.
|
|
197
206
|
* ``PERMISSIONS`` — the permission source for the generated viewsets (and for
|
|
@@ -2,6 +2,7 @@ from django.apps import apps
|
|
|
2
2
|
from django.core.exceptions import ImproperlyConfigured
|
|
3
3
|
from rest_framework import serializers
|
|
4
4
|
from . import settings
|
|
5
|
+
from .utils import resolve_apps
|
|
5
6
|
|
|
6
7
|
# Field-level kwargs configuring the inline formset rendered for a declared
|
|
7
8
|
# writable nested serializer (see ``Metadata``). DRF would otherwise forward them
|
|
@@ -106,7 +107,7 @@ class GenericAutocompleteSerializer(serializers.ModelSerializer):
|
|
|
106
107
|
|
|
107
108
|
######################
|
|
108
109
|
|
|
109
|
-
for app in
|
|
110
|
+
for app, _app_module in resolve_apps():
|
|
110
111
|
for name, model in apps.all_models[app].items():
|
|
111
112
|
model_name = model.__name__
|
|
112
113
|
if isinstance(model, type):
|
|
@@ -5,15 +5,18 @@ from django.core.exceptions import FieldDoesNotExist
|
|
|
5
5
|
from rest_framework import serializers as drf_serializers
|
|
6
6
|
|
|
7
7
|
from . import settings, autocomplete_serializers, viewsets
|
|
8
|
-
from .utils import camel_to_snake, to_pascal_case
|
|
8
|
+
from .utils import camel_to_snake, resolve_apps, to_pascal_case
|
|
9
9
|
|
|
10
10
|
# ``settings`` is ``django.conf.settings.__dict__`` (see the package ``__init__``):
|
|
11
11
|
# ``override_settings`` clears that dict when it swaps ``_wrapped``, so the apps
|
|
12
12
|
# list is snapshotted here (as the generation loop below already implicitly is).
|
|
13
|
-
|
|
13
|
+
# Entries are normalized to ``(label, module_path)`` pairs; see
|
|
14
|
+
# ``utils.resolve_app_entry``.
|
|
15
|
+
_APP_ENTRIES = tuple(resolve_apps())
|
|
16
|
+
_APPS = tuple(label for label, _module in _APP_ENTRIES)
|
|
14
17
|
|
|
15
18
|
|
|
16
|
-
for app in
|
|
19
|
+
for app, app_module in _APP_ENTRIES:
|
|
17
20
|
for name, model in apps.all_models[app].items():
|
|
18
21
|
model_name = model.__name__
|
|
19
22
|
if isinstance(model, type):
|
|
@@ -25,6 +28,7 @@ for app in _APPS:
|
|
|
25
28
|
{
|
|
26
29
|
"model_name": model_name,
|
|
27
30
|
"app": app,
|
|
31
|
+
"app_module": app_module,
|
|
28
32
|
"serializer_class": getattr(
|
|
29
33
|
autocomplete_serializers, f"{model_name}Serializer"
|
|
30
34
|
),
|
|
@@ -65,9 +69,9 @@ def _iter_serializer_classes():
|
|
|
65
69
|
from . import serializers as generated_serializers
|
|
66
70
|
|
|
67
71
|
modules = [generated_serializers]
|
|
68
|
-
for
|
|
72
|
+
for _label, app_module in _APP_ENTRIES:
|
|
69
73
|
try:
|
|
70
|
-
modules.append(importlib.import_module(f"{
|
|
74
|
+
modules.append(importlib.import_module(f"{app_module}.serializers"))
|
|
71
75
|
except ImportError:
|
|
72
76
|
pass
|
|
73
77
|
|
|
@@ -28,8 +28,12 @@ def _first_geometry_field(model):
|
|
|
28
28
|
def geodjango_libraries_available(app_configs, **kwargs):
|
|
29
29
|
from django.conf import settings
|
|
30
30
|
|
|
31
|
+
from .utils import resolve_apps
|
|
32
|
+
|
|
31
33
|
drf_settings = getattr(settings, "DRF_REACT_BY_SCHEMA", {}) or {}
|
|
32
|
-
app_labels =
|
|
34
|
+
app_labels = [
|
|
35
|
+
label for label, _module in resolve_apps(drf_settings.get("APPS", ["main"]))
|
|
36
|
+
]
|
|
33
37
|
|
|
34
38
|
for app_label in app_labels:
|
|
35
39
|
try:
|
{drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/serializers.py
RENAMED
|
@@ -27,6 +27,7 @@ from .utils import (
|
|
|
27
27
|
fill_required_related_ids,
|
|
28
28
|
is_tmp_id,
|
|
29
29
|
register_nested_write,
|
|
30
|
+
resolve_apps,
|
|
30
31
|
update_related_fields,
|
|
31
32
|
)
|
|
32
33
|
|
|
@@ -942,7 +943,7 @@ def list_serializer_for(detail_class):
|
|
|
942
943
|
######################
|
|
943
944
|
|
|
944
945
|
|
|
945
|
-
for app in
|
|
946
|
+
for app, _app_module in resolve_apps():
|
|
946
947
|
for name, model in apps.all_models[app].items():
|
|
947
948
|
model_name = model.__name__
|
|
948
949
|
if isinstance(model, type):
|
|
@@ -18,11 +18,11 @@ class NonEditableRelatedFieldTest(TestCase):
|
|
|
18
18
|
def test_non_editable_related_fields_listed_but_not_written(self):
|
|
19
19
|
from django.apps import apps
|
|
20
20
|
|
|
21
|
-
from drf_react_by_schema import settings
|
|
22
21
|
from drf_react_by_schema import serializers as pkg_serializers
|
|
22
|
+
from drf_react_by_schema.utils import resolve_apps
|
|
23
23
|
|
|
24
24
|
checked = 0
|
|
25
|
-
for app in
|
|
25
|
+
for app, _app_module in resolve_apps():
|
|
26
26
|
for model in apps.all_models[app].values():
|
|
27
27
|
if not isinstance(model, type):
|
|
28
28
|
continue
|
|
@@ -4,8 +4,7 @@ from rest_framework_nested import routers
|
|
|
4
4
|
import importlib
|
|
5
5
|
import traceback
|
|
6
6
|
|
|
7
|
-
from . import
|
|
8
|
-
from .utils import camel_to_snake
|
|
7
|
+
from .utils import camel_to_snake, resolve_apps
|
|
9
8
|
from .views import SchemaBundleView, UploadView
|
|
10
9
|
from .viewsets import __nested_viewsets__
|
|
11
10
|
|
|
@@ -15,9 +14,9 @@ nested_routers = {}
|
|
|
15
14
|
|
|
16
15
|
modules = []
|
|
17
16
|
autocomplete_modules = []
|
|
18
|
-
for
|
|
19
|
-
modules.append(f"{
|
|
20
|
-
autocomplete_modules.append(f"{
|
|
17
|
+
for _label, app_module in resolve_apps():
|
|
18
|
+
modules.append(f"{app_module}.viewsets")
|
|
19
|
+
autocomplete_modules.append(f"{app_module}.autocomplete_viewsets")
|
|
21
20
|
modules.append("drf_react_by_schema.viewsets")
|
|
22
21
|
autocomplete_modules.append("drf_react_by_schema.autocomplete_viewsets")
|
|
23
22
|
|
|
@@ -376,6 +376,43 @@ def get_model(app, model_name):
|
|
|
376
376
|
return apps.get_model(app_label=app, model_name=model_name)
|
|
377
377
|
|
|
378
378
|
|
|
379
|
+
def resolve_app_entry(entry):
|
|
380
|
+
"""Normalize one ``DRF_REACT_BY_SCHEMA["APPS"]`` entry.
|
|
381
|
+
|
|
382
|
+
An entry is either an app label (``"main"``) or a dotted module path
|
|
383
|
+
(``"eita_balaio.produtos"``). The dotted form lets a distribution ship its
|
|
384
|
+
Django app nested inside its own package instead of occupying a top-level
|
|
385
|
+
name; Django only requires the app *label* to be a bare identifier.
|
|
386
|
+
|
|
387
|
+
Returns ``(label, module_path)``. The label keys ``apps.all_models`` and
|
|
388
|
+
matches ``Model._meta.app_label``; the module path is what gets imported as
|
|
389
|
+
``<module_path>.viewsets`` / ``<module_path>.serializers`` /
|
|
390
|
+
``<module_path>.autocomplete_viewsets``.
|
|
391
|
+
"""
|
|
392
|
+
if "." not in entry:
|
|
393
|
+
return entry, entry
|
|
394
|
+
app_config = apps.get_containing_app_config(entry)
|
|
395
|
+
if app_config is not None:
|
|
396
|
+
return app_config.label, app_config.name
|
|
397
|
+
# Not an installed app (typo, or installed under another name): fall back to
|
|
398
|
+
# the conventional label so the caller's import fails the same way a bad
|
|
399
|
+
# plain label would.
|
|
400
|
+
return entry.rpartition(".")[2], entry
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
def resolve_apps(entries=None):
|
|
404
|
+
"""``[(label, module_path), ...]`` for the configured apps.
|
|
405
|
+
|
|
406
|
+
``entries`` defaults to the package's ``settings["APPS"]`` (the list injected
|
|
407
|
+
from ``DRF_REACT_BY_SCHEMA`` at import time).
|
|
408
|
+
"""
|
|
409
|
+
if entries is None:
|
|
410
|
+
from . import settings
|
|
411
|
+
|
|
412
|
+
entries = settings.get("APPS", ["main"])
|
|
413
|
+
return [resolve_app_entry(entry) for entry in entries]
|
|
414
|
+
|
|
415
|
+
|
|
379
416
|
def camel_to_snake(name, suffix=None):
|
|
380
417
|
if suffix:
|
|
381
418
|
name = name.removesuffix(suffix)
|
|
@@ -52,6 +52,11 @@ class DRFReactBySchemaBaseModelViewSet(
|
|
|
52
52
|
serializer_list_class = None
|
|
53
53
|
model = None
|
|
54
54
|
app = None
|
|
55
|
+
#: Import path for ``<module>.viewsets``/``<module>.serializers``. Differs
|
|
56
|
+
#: from ``app`` only when the app is configured by a dotted module path
|
|
57
|
+
#: (``eita_balaio.produtos`` -> label ``produtos``); see
|
|
58
|
+
#: ``utils.resolve_app_entry``.
|
|
59
|
+
app_module = None
|
|
55
60
|
model_name = None
|
|
56
61
|
many = True
|
|
57
62
|
reverse_many = False
|
|
@@ -80,7 +85,8 @@ class DRFReactBySchemaBaseModelViewSet(
|
|
|
80
85
|
super().__init__(*args, **kwargs)
|
|
81
86
|
if not self.model and self.model_name:
|
|
82
87
|
self.model = utils.get_model(self.app, self.model_name)
|
|
83
|
-
|
|
88
|
+
app_module = self.app_module or self.app
|
|
89
|
+
if app_module and self.serializer_class is not None:
|
|
84
90
|
module_name = (
|
|
85
91
|
"autocomplete_serializers"
|
|
86
92
|
if self.is_autocomplete
|
|
@@ -88,7 +94,7 @@ class DRFReactBySchemaBaseModelViewSet(
|
|
|
88
94
|
)
|
|
89
95
|
try:
|
|
90
96
|
app_serializers = importlib.import_module(
|
|
91
|
-
f"{
|
|
97
|
+
f"{app_module}.{module_name}"
|
|
92
98
|
)
|
|
93
99
|
except ImportError:
|
|
94
100
|
return
|
|
@@ -768,7 +774,7 @@ class PasswordResetViewSet(viewsets.ViewSet):
|
|
|
768
774
|
##########################
|
|
769
775
|
__nested_viewsets__ = []
|
|
770
776
|
|
|
771
|
-
for app in
|
|
777
|
+
for app, app_module in utils.resolve_apps():
|
|
772
778
|
for name, model in apps.all_models[app].items():
|
|
773
779
|
model_name = model.__name__
|
|
774
780
|
if isinstance(model, type):
|
|
@@ -780,6 +786,7 @@ for app in settings["APPS"]:
|
|
|
780
786
|
{
|
|
781
787
|
"model_name": model_name,
|
|
782
788
|
"app": app,
|
|
789
|
+
"app_module": app_module,
|
|
783
790
|
"serializer_class": getattr(
|
|
784
791
|
serializers, f"{model_name}Serializer"
|
|
785
792
|
),
|
|
@@ -810,6 +817,7 @@ for app in settings["APPS"]:
|
|
|
810
817
|
{
|
|
811
818
|
"model": field.related_model,
|
|
812
819
|
"app": app,
|
|
820
|
+
"app_module": app_module,
|
|
813
821
|
"serializer_class": getattr(
|
|
814
822
|
serializers, f"{related_model_name}Serializer"
|
|
815
823
|
),
|
|
@@ -829,7 +837,7 @@ for app in settings["APPS"]:
|
|
|
829
837
|
class EndpointsViewSet(viewsets.ViewSet):
|
|
830
838
|
def list(self, request):
|
|
831
839
|
endpoints = []
|
|
832
|
-
for app in
|
|
840
|
+
for app, _app_module in utils.resolve_apps():
|
|
833
841
|
for name, model in apps.all_models[app].items():
|
|
834
842
|
endpoint = {
|
|
835
843
|
"model_name": utils.camel_to_snake(model.__name__),
|
{drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema.egg-info/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: drf-react-by-schema
|
|
3
|
-
Version: 0.29.
|
|
3
|
+
Version: 0.29.3
|
|
4
4
|
Summary: A Django app to easily integrate with React from models.
|
|
5
5
|
Home-page: https://gitlab.com/eita/drf-react-by-schema/drf-react-by-schema-django
|
|
6
6
|
Author: Cooperativa EITA
|
|
@@ -164,7 +164,10 @@ Installation and quick start
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
4. Configure ``DRF_REACT_BY_SCHEMA``. The only required entry is the list of apps
|
|
167
|
-
whose models should get an endpoint (default ``['main']``)
|
|
167
|
+
whose models should get an endpoint (default ``['main']``). Each entry is an app
|
|
168
|
+
label (``'main'``) or a dotted module path (``'my_package.produtos'``) — the
|
|
169
|
+
dotted form lets a distribution ship its Django app nested inside its own
|
|
170
|
+
package instead of taking a top-level name:
|
|
168
171
|
|
|
169
172
|
.. code-block:: python
|
|
170
173
|
|
|
@@ -222,9 +225,15 @@ Configuration reference
|
|
|
222
225
|
``DRF_REACT_BY_SCHEMA`` is the only settings block the package reads (via
|
|
223
226
|
``settings.get("DRF_REACT_BY_SCHEMA", {})``):
|
|
224
227
|
|
|
225
|
-
* ``APPS`` (default ``["main"]``) — the
|
|
226
|
-
serializers, viewsets and routes.
|
|
227
|
-
``
|
|
228
|
+
* ``APPS`` (default ``["main"]``) — the apps whose models get generated
|
|
229
|
+
serializers, viewsets and routes. Each entry is an app label (``"main"``) or a
|
|
230
|
+
dotted module path (``"my_package.produtos"``); the dotted form lets a
|
|
231
|
+
distribution ship its Django app nested inside its own package instead of
|
|
232
|
+
occupying a top-level name. ``utils.resolve_apps()`` normalizes an entry to
|
|
233
|
+
``(label, module_path)`` — the label keys ``apps.all_models`` and matches
|
|
234
|
+
``Model._meta.app_label``, while the module path is imported as
|
|
235
|
+
``<module>.viewsets`` / ``<module>.serializers``. Consumed by ``urls.py``,
|
|
236
|
+
``viewsets.py``, ``serializers.py``, the autocomplete modules and ``sync_react``.
|
|
228
237
|
* ``REACT_APP_DIR`` (default ``"frontend"``) — where ``sync_react`` writes
|
|
229
238
|
``src/drfReactBySchema/``, resolved as ``os.path.join(settings.BASE_DIR, REACT_APP_DIR)``.
|
|
230
239
|
* ``PERMISSIONS`` — the permission source for the generated viewsets (and for
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/fields/__init__.py
RENAMED
|
File without changes
|
{drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/fields/array.py
RENAMED
|
File without changes
|
{drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/fields/boolean.py
RENAMED
|
File without changes
|
{drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/fields/date.py
RENAMED
|
File without changes
|
{drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/fields/file.py
RENAMED
|
File without changes
|
{drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/fields/geometry.py
RENAMED
|
File without changes
|
{drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/fields/number.py
RENAMED
|
File without changes
|
{drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/fields/relational.py
RENAMED
|
File without changes
|
{drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/fields/serializers.py
RENAMED
|
File without changes
|
{drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/fields/text.py
RENAMED
|
File without changes
|
|
File without changes
|
{drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/management/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/migrations/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/patches/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/schema_bundle.py
RENAMED
|
File without changes
|
|
File without changes
|
{drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema/utils_cache.py
RENAMED
|
File without changes
|
|
File without changes
|
{drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema.egg-info/requires.txt
RENAMED
|
File without changes
|
{drf_react_by_schema-0.29.2 → drf_react_by_schema-0.29.3}/drf_react_by_schema.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|