rn-forge-django 0.6.0__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.
Files changed (75) hide show
  1. rn_forge_django-0.6.0/LICENSE +21 -0
  2. rn_forge_django-0.6.0/PKG-INFO +203 -0
  3. rn_forge_django-0.6.0/README.md +142 -0
  4. rn_forge_django-0.6.0/pyproject.toml +141 -0
  5. rn_forge_django-0.6.0/pyproject.toml.orig +147 -0
  6. rn_forge_django-0.6.0/src/rn_forge/django/__init__.py +3 -0
  7. rn_forge_django-0.6.0/src/rn_forge/django/_typing.py +77 -0
  8. rn_forge_django-0.6.0/src/rn_forge/django/auth/__init__.py +43 -0
  9. rn_forge_django-0.6.0/src/rn_forge/django/auth/_typing.py +24 -0
  10. rn_forge_django-0.6.0/src/rn_forge/django/auth/accounts.py +206 -0
  11. rn_forge_django-0.6.0/src/rn_forge/django/auth/admin.py +99 -0
  12. rn_forge_django-0.6.0/src/rn_forge/django/auth/apps.py +14 -0
  13. rn_forge_django-0.6.0/src/rn_forge/django/auth/authorization.py +191 -0
  14. rn_forge_django-0.6.0/src/rn_forge/django/auth/csrf.py +162 -0
  15. rn_forge_django-0.6.0/src/rn_forge/django/auth/drf/__init__.py +43 -0
  16. rn_forge_django-0.6.0/src/rn_forge/django/auth/drf/authorization.py +106 -0
  17. rn_forge_django-0.6.0/src/rn_forge/django/auth/drf/oidc.py +63 -0
  18. rn_forge_django-0.6.0/src/rn_forge/django/auth/drf/principal.py +164 -0
  19. rn_forge_django-0.6.0/src/rn_forge/django/auth/drf/serializers.py +140 -0
  20. rn_forge_django-0.6.0/src/rn_forge/django/auth/drf/session.py +81 -0
  21. rn_forge_django-0.6.0/src/rn_forge/django/auth/drf/views.py +67 -0
  22. rn_forge_django-0.6.0/src/rn_forge/django/auth/migrations/0001_initial.py +64 -0
  23. rn_forge_django-0.6.0/src/rn_forge/django/auth/migrations/__init__.py +0 -0
  24. rn_forge_django-0.6.0/src/rn_forge/django/auth/models.py +53 -0
  25. rn_forge_django-0.6.0/src/rn_forge/django/auth/rate_limit.py +80 -0
  26. rn_forge_django-0.6.0/src/rn_forge/django/auth/routes.py +591 -0
  27. rn_forge_django-0.6.0/src/rn_forge/django/auth/sessions.py +238 -0
  28. rn_forge_django-0.6.0/src/rn_forge/django/auth/stores.py +113 -0
  29. rn_forge_django-0.6.0/src/rn_forge/django/auth/urls.py +24 -0
  30. rn_forge_django-0.6.0/src/rn_forge/django/celery.py +43 -0
  31. rn_forge_django-0.6.0/src/rn_forge/django/cors.py +42 -0
  32. rn_forge_django-0.6.0/src/rn_forge/django/deprecation.py +51 -0
  33. rn_forge_django-0.6.0/src/rn_forge/django/drf/__init__.py +39 -0
  34. rn_forge_django-0.6.0/src/rn_forge/django/drf/_typing.py +136 -0
  35. rn_forge_django-0.6.0/src/rn_forge/django/drf/casing.py +147 -0
  36. rn_forge_django-0.6.0/src/rn_forge/django/drf/concurrency.py +79 -0
  37. rn_forge_django-0.6.0/src/rn_forge/django/drf/exceptions.py +187 -0
  38. rn_forge_django-0.6.0/src/rn_forge/django/drf/idempotency.py +154 -0
  39. rn_forge_django-0.6.0/src/rn_forge/django/drf/openapi.py +296 -0
  40. rn_forge_django-0.6.0/src/rn_forge/django/drf/pagination.py +302 -0
  41. rn_forge_django-0.6.0/src/rn_forge/django/drf/routers.py +68 -0
  42. rn_forge_django-0.6.0/src/rn_forge/django/drf/serializers/__init__.py +14 -0
  43. rn_forge_django-0.6.0/src/rn_forge/django/drf/serializers/base.py +52 -0
  44. rn_forge_django-0.6.0/src/rn_forge/django/drf/serializers/fields.py +119 -0
  45. rn_forge_django-0.6.0/src/rn_forge/django/drf/transfer.py +698 -0
  46. rn_forge_django-0.6.0/src/rn_forge/django/drf/urls.py +18 -0
  47. rn_forge_django-0.6.0/src/rn_forge/django/drf/utils.py +127 -0
  48. rn_forge_django-0.6.0/src/rn_forge/django/drf/views/__init__.py +26 -0
  49. rn_forge_django-0.6.0/src/rn_forge/django/drf/views/base.py +36 -0
  50. rn_forge_django-0.6.0/src/rn_forge/django/drf/views/enums.py +57 -0
  51. rn_forge_django-0.6.0/src/rn_forge/django/drf/views/mixins.py +522 -0
  52. rn_forge_django-0.6.0/src/rn_forge/django/exceptions.py +157 -0
  53. rn_forge_django-0.6.0/src/rn_forge/django/fixtures.py +265 -0
  54. rn_forge_django-0.6.0/src/rn_forge/django/messaging/__init__.py +9 -0
  55. rn_forge_django-0.6.0/src/rn_forge/django/messaging/apps.py +13 -0
  56. rn_forge_django-0.6.0/src/rn_forge/django/messaging/consumer.py +91 -0
  57. rn_forge_django-0.6.0/src/rn_forge/django/messaging/models.py +60 -0
  58. rn_forge_django-0.6.0/src/rn_forge/django/messaging/relay.py +76 -0
  59. rn_forge_django-0.6.0/src/rn_forge/django/models/__init__.py +50 -0
  60. rn_forge_django-0.6.0/src/rn_forge/django/models/_meta.py +47 -0
  61. rn_forge_django-0.6.0/src/rn_forge/django/models/base.py +224 -0
  62. rn_forge_django-0.6.0/src/rn_forge/django/models/cache.py +71 -0
  63. rn_forge_django-0.6.0/src/rn_forge/django/models/concurrency.py +165 -0
  64. rn_forge_django-0.6.0/src/rn_forge/django/models/enums.py +50 -0
  65. rn_forge_django-0.6.0/src/rn_forge/django/models/fields.py +69 -0
  66. rn_forge_django-0.6.0/src/rn_forge/django/models/sequences.py +129 -0
  67. rn_forge_django-0.6.0/src/rn_forge/django/models/soft_delete.py +65 -0
  68. rn_forge_django-0.6.0/src/rn_forge/django/models/utils.py +79 -0
  69. rn_forge_django-0.6.0/src/rn_forge/django/py.typed +0 -0
  70. rn_forge_django-0.6.0/src/rn_forge/django/security.py +55 -0
  71. rn_forge_django-0.6.0/src/rn_forge/django/settings.py +230 -0
  72. rn_forge_django-0.6.0/src/rn_forge/django/tracing.py +34 -0
  73. rn_forge_django-0.6.0/src/rn_forge/django/urls.py +14 -0
  74. rn_forge_django-0.6.0/src/rn_forge/django/utils.py +49 -0
  75. rn_forge_django-0.6.0/src/rn_forge/django/views.py +201 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rohit Narayanan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,203 @@
1
+ Metadata-Version: 2.4
2
+ Name: rn-forge-django
3
+ Version: 0.6.0
4
+ Summary: Opinionated Django/DRF integration layer built on rn-forge-commons and rn-forge-web
5
+ Author: Rohit Narayanan
6
+ Author-email: Rohit Narayanan <rohit.nn@gmail.com>
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Framework :: Django
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Classifier: Typing :: Typed
17
+ Requires-Dist: django>=6.0.7
18
+ Requires-Dist: rn-forge-auth>=0.1.0,<0.2
19
+ Requires-Dist: rn-forge-commons>=0.8.0,<0.9
20
+ Requires-Dist: rn-forge-web>=0.3.0,<0.4
21
+ Requires-Dist: celery>=5.6.3 ; extra == 'all'
22
+ Requires-Dist: django-cors-headers>=4.9.0 ; extra == 'all'
23
+ Requires-Dist: django-import-export>=4.4.1 ; extra == 'all'
24
+ Requires-Dist: djangorestframework>=3.17.1 ; extra == 'all'
25
+ Requires-Dist: drf-spectacular>=0.30.0 ; extra == 'all'
26
+ Requires-Dist: opentelemetry-instrumentation-django>=0.65b0 ; extra == 'all'
27
+ Requires-Dist: rn-forge-auth[oidc,redis]>=0.1.0,<0.2 ; extra == 'all'
28
+ Requires-Dist: rn-forge-data[pandas]>=0.1.1,<0.2 ; extra == 'all'
29
+ Requires-Dist: rn-forge-web[security]>=0.3.0,<0.4 ; extra == 'all'
30
+ Requires-Dist: celery>=5.6.3 ; extra == 'celery'
31
+ Requires-Dist: django-cors-headers>=4.9.0 ; extra == 'cors'
32
+ Requires-Dist: djangorestframework>=3.17.1 ; extra == 'drf'
33
+ Requires-Dist: rn-forge-data[pandas]>=0.1.1,<0.2 ; extra == 'fixtures'
34
+ Requires-Dist: djangorestframework>=3.17.1 ; extra == 'oidc'
35
+ Requires-Dist: rn-forge-auth[oidc]>=0.1.0,<0.2 ; extra == 'oidc'
36
+ Requires-Dist: djangorestframework>=3.17.1 ; extra == 'openapi'
37
+ Requires-Dist: drf-spectacular>=0.30.0 ; extra == 'openapi'
38
+ Requires-Dist: opentelemetry-instrumentation-django>=0.65b0 ; extra == 'otel'
39
+ Requires-Dist: rn-forge-auth[redis]>=0.1.0,<0.2 ; extra == 'redis'
40
+ Requires-Dist: rn-forge-web[security]>=0.3.0,<0.4 ; extra == 'security'
41
+ Requires-Dist: djangorestframework>=3.17.1 ; extra == 'transfer'
42
+ Requires-Dist: django-import-export>=4.4.1 ; extra == 'transfer'
43
+ Requires-Dist: rn-forge-data>=0.1.1,<0.2 ; extra == 'transfer'
44
+ Requires-Python: >=3.14
45
+ Project-URL: Documentation, https://rn-forge.github.io/pykit/packages/rn-forge-django/latest/
46
+ Project-URL: Source, https://github.com/rn-forge/pykit/tree/main/packages/rn-forge-django
47
+ Project-URL: Changelog, https://github.com/rn-forge/pykit/blob/main/packages/rn-forge-django/CHANGELOG.md
48
+ Project-URL: Issues, https://github.com/rn-forge/pykit/issues
49
+ Provides-Extra: all
50
+ Provides-Extra: celery
51
+ Provides-Extra: cors
52
+ Provides-Extra: drf
53
+ Provides-Extra: fixtures
54
+ Provides-Extra: oidc
55
+ Provides-Extra: openapi
56
+ Provides-Extra: otel
57
+ Provides-Extra: redis
58
+ Provides-Extra: security
59
+ Provides-Extra: transfer
60
+ Description-Content-Type: text/markdown
61
+
62
+ # rn-forge-django
63
+
64
+ [Documentation](https://rn-forge.github.io/pykit/packages/rn-forge-django/latest/)
65
+ ·
66
+ [Changelog](https://github.com/rn-forge/pykit/blob/main/packages/rn-forge-django/CHANGELOG.md)
67
+ · [Source](https://github.com/rn-forge/pykit/tree/main/packages/rn-forge-django)
68
+ · [All pykit packages](https://rn-forge.github.io/pykit/)
69
+
70
+ Opinionated Django/DRF integration layer built on top of
71
+ [`rn-forge-commons`](https://github.com/rn-forge/pykit/tree/main/packages/rn-forge-commons)
72
+ and
73
+ [`rn-forge-web`](https://github.com/rn-forge/pykit/tree/main/packages/rn-forge-web).
74
+
75
+ ## Install
76
+
77
+ Require the package by version range:
78
+
79
+ ```bash
80
+ uv add "rn-forge-django[all]>=0.6,<0.7"
81
+ ```
82
+
83
+ Application code imports `rn_forge.web` directly (wire models, pagination,
84
+ problem types, the auth contract), and this package does not re-export it.
85
+ Declare `rn-forge-web` as well, so the import is not an undeclared transitive
86
+ dependency:
87
+
88
+ ```bash
89
+ uv add "rn-forge-web>=0.3,<0.4"
90
+ ```
91
+
92
+ Optional extras:
93
+
94
+ | Extra | Adds |
95
+ | -- | -- |
96
+ | `drf` | Django REST Framework integration (views, serializers, exceptions, pagination, idempotency, concurrency, casing) |
97
+ | `transfer` | `django-import-export` + `rn-forge-data` (`tablib`, `openpyxl`), for `rn_forge.django.drf.transfer`: tabular export and import, batch create and delete |
98
+ | `openapi` | `drf-spectacular`, for `drf.openapi` |
99
+ | `oidc` | `rn-forge-auth[oidc]` (`pyjwt[crypto]`), for `auth.drf.oidc` JWKS bearer auth |
100
+ | `redis` | `rn-forge-auth[redis]`, the Redis client for Django's Redis cache backend that holds login transactions and revoked session IDs |
101
+ | `celery` | `celery`, for the `celery` app factory |
102
+ | `fixtures` | `rn-forge-data[pandas]`, for building Django JSON fixtures from Excel workbooks |
103
+ | `all` | Everything above |
104
+
105
+ ## What's inside
106
+
107
+ - **`models`** — Abstract model base classes: `BaseModel` (status enum field,
108
+ audit timestamps, natural-key fixture support via
109
+ `NaturalKeyLookupManager`/`FixtureModelMixin`, opt-in
110
+ `full_clean()`-on-save), `DateModel`, `DateRangeModel`,
111
+ `TruncateModelMixin`; the opt-in `VersionedModelMixin`/`ImmutableModelMixin`;
112
+ and `SequenceGenerator` over an abstract counter.
113
+ - **`auth`** — An installable Django app (`rn_forge.django.auth`, label
114
+ `rn_forge_django_auth`) that binds `rn-forge-auth` to Django and DRF:
115
+ `routes` (the `/auth` URLconf and its configuration), `sessions`
116
+ (`django.contrib.sessions` sessions with timeouts and revocation), `csrf`
117
+ (CSRF middleware and settings), `stores` (login transactions and replay
118
+ records in Django's cache), `rate_limit`, `audit` (audit events),
119
+ `accounts` and `models` (the default account resolver and its link and state
120
+ tables), `authorization` (the default authorization context provider), and
121
+ `auth.drf` (session and bearer authentication, permission-key and
122
+ resource-policy hooks, serializers and the management viewsets).
123
+ - **`drf`** — DRF integration outside the auth app: `drf.views` (base view
124
+ classes, mixins, `PermissionByMethodMixin`), `drf.routers`
125
+ (`CustomMethodRouter`, AIP-136 colon custom methods), `drf.transfer`
126
+ (`transfer` extra: tabular export/import, batch create/delete),
127
+ `drf.serializers` (base serializer, custom fields), `drf.exceptions` (the
128
+ RFC 9457 problem handler and the legacy handler), `drf.pagination` (AIP-158
129
+ cursor pagination), `drf.idempotency`, `drf.concurrency`, `drf.casing`
130
+ (camelCase renderer/parser) and `drf.openapi` (drf-spectacular; `openapi`
131
+ extra).
132
+ - **`tracing`** (`otel` extra) — `instrument()`: OpenTelemetry instrumentation
133
+ for Django, called once before Django loads.
134
+ - **`messaging`** — transactional outbox/inbox: abstract models,
135
+ `make_outbox_relay`, `process_event` (bus and handler registry come from
136
+ `rn_forge.commons.integration.messaging`).
137
+ - **`celery`** (`celery` extra) — `make_app` and `RETRYABLE_TASK_KWARGS`.
138
+ - **`settings`** — `rn_forge_django_settings`: a typed, frozen-dataclass
139
+ settings facade built from the Django `RN_FORGE_DJANGO` setting dict,
140
+ auto-reloaded on `override_settings`/`setting_changed`.
141
+ - **`fixtures`** — Builds Django JSON fixtures from Excel workbooks (requires
142
+ the `fixtures` extra).
143
+ - **`urls`** / **`views`** — Reusable standalone views (including the
144
+ `readiness_view` factory and `debug_request`) and URLconf; `utils` carries
145
+ the `require_settings`/`require_environment` startup guards.
146
+
147
+ The HTTP wire semantics — problem bodies, preconditions, pagination tokens,
148
+ idempotency keys, readiness reports, the auth contract — are `rn-forge-web`'s.
149
+ Everything here that touches them is an adapter, and `tests/test_conformance.py`
150
+ drives the shared conformance table through a Django application wired from
151
+ them.
152
+
153
+ ## Dependencies and package behavior
154
+
155
+ - **`rn-forge-web`** is a base dependency: five modules are adapters over it.
156
+ - **`rn-forge-auth`** is a base dependency: `auth` binds its login flows,
157
+ stores, `Principal`, `Requirement` and authorization contracts to Django and
158
+ DRF.
159
+ - **`drf-spectacular`** (`openapi` extra) supplies the OpenAPI schema
160
+ integration.
161
+ - **`drf.casing`** supplies the camelCase renderer and parser.
162
+ - **`oidc` extra** — JWKS verification is `rn-forge-auth[oidc]` (PyJWT);
163
+ `auth.drf.oidc` only binds it to DRF.
164
+ - **`celery` extra** — supplies the Celery app factory.
165
+ - **Migrations.** The auth app has one, for the external-account link and
166
+ account-state tables. `SequenceGenerator`'s counter is abstract and adds no
167
+ table.
168
+
169
+ ## Configuration
170
+
171
+ Settings are read from a single `RN_FORGE_DJANGO` dict in your Django settings
172
+ module, e.g.:
173
+
174
+ ```python
175
+ RN_FORGE_DJANGO = {
176
+ "AUTH": {"PROBLEM_TYPE_BASE": "https://errors.example.com/"},
177
+ "DRF": {
178
+ "TRANSFER": {"MAX_ROWS": 10_000},
179
+ "PAGINATION": {"PAGE_SIZE": 50, "MAX_PAGE_SIZE": 200},
180
+ "CASING": {"ENABLED": True},
181
+ },
182
+ }
183
+ ```
184
+
185
+ To use the bundled auth app, add `"rn_forge.django.auth"` to `INSTALLED_APPS`.
186
+
187
+ ## Development
188
+
189
+ From the repo root or this directory:
190
+
191
+ ```bash
192
+ uv run pytest packages/rn-forge-django # all tests
193
+ uv run pytest packages/rn-forge-django -m unit # fast isolated tests
194
+ uv run pytest packages/rn-forge-django -m integration # database-backed tests
195
+ uv run ruff check packages/rn-forge-django
196
+ uv run pyright
197
+ ```
198
+
199
+ Tests configure Django directly in
200
+ [`tests/conftest.py`](https://github.com/rn-forge/pykit/blob/main/packages/rn-forge-django/tests/conftest.py)
201
+ (sqlite in-memory database) — there is no separate Django settings module.
202
+ Test-only models and their tables follow the convention in that file's
203
+ docstring.
@@ -0,0 +1,142 @@
1
+ # rn-forge-django
2
+
3
+ [Documentation](https://rn-forge.github.io/pykit/packages/rn-forge-django/latest/)
4
+ ·
5
+ [Changelog](https://github.com/rn-forge/pykit/blob/main/packages/rn-forge-django/CHANGELOG.md)
6
+ · [Source](https://github.com/rn-forge/pykit/tree/main/packages/rn-forge-django)
7
+ · [All pykit packages](https://rn-forge.github.io/pykit/)
8
+
9
+ Opinionated Django/DRF integration layer built on top of
10
+ [`rn-forge-commons`](https://github.com/rn-forge/pykit/tree/main/packages/rn-forge-commons)
11
+ and
12
+ [`rn-forge-web`](https://github.com/rn-forge/pykit/tree/main/packages/rn-forge-web).
13
+
14
+ ## Install
15
+
16
+ Require the package by version range:
17
+
18
+ ```bash
19
+ uv add "rn-forge-django[all]>=0.6,<0.7"
20
+ ```
21
+
22
+ Application code imports `rn_forge.web` directly (wire models, pagination,
23
+ problem types, the auth contract), and this package does not re-export it.
24
+ Declare `rn-forge-web` as well, so the import is not an undeclared transitive
25
+ dependency:
26
+
27
+ ```bash
28
+ uv add "rn-forge-web>=0.3,<0.4"
29
+ ```
30
+
31
+ Optional extras:
32
+
33
+ | Extra | Adds |
34
+ | -- | -- |
35
+ | `drf` | Django REST Framework integration (views, serializers, exceptions, pagination, idempotency, concurrency, casing) |
36
+ | `transfer` | `django-import-export` + `rn-forge-data` (`tablib`, `openpyxl`), for `rn_forge.django.drf.transfer`: tabular export and import, batch create and delete |
37
+ | `openapi` | `drf-spectacular`, for `drf.openapi` |
38
+ | `oidc` | `rn-forge-auth[oidc]` (`pyjwt[crypto]`), for `auth.drf.oidc` JWKS bearer auth |
39
+ | `redis` | `rn-forge-auth[redis]`, the Redis client for Django's Redis cache backend that holds login transactions and revoked session IDs |
40
+ | `celery` | `celery`, for the `celery` app factory |
41
+ | `fixtures` | `rn-forge-data[pandas]`, for building Django JSON fixtures from Excel workbooks |
42
+ | `all` | Everything above |
43
+
44
+ ## What's inside
45
+
46
+ - **`models`** — Abstract model base classes: `BaseModel` (status enum field,
47
+ audit timestamps, natural-key fixture support via
48
+ `NaturalKeyLookupManager`/`FixtureModelMixin`, opt-in
49
+ `full_clean()`-on-save), `DateModel`, `DateRangeModel`,
50
+ `TruncateModelMixin`; the opt-in `VersionedModelMixin`/`ImmutableModelMixin`;
51
+ and `SequenceGenerator` over an abstract counter.
52
+ - **`auth`** — An installable Django app (`rn_forge.django.auth`, label
53
+ `rn_forge_django_auth`) that binds `rn-forge-auth` to Django and DRF:
54
+ `routes` (the `/auth` URLconf and its configuration), `sessions`
55
+ (`django.contrib.sessions` sessions with timeouts and revocation), `csrf`
56
+ (CSRF middleware and settings), `stores` (login transactions and replay
57
+ records in Django's cache), `rate_limit`, `audit` (audit events),
58
+ `accounts` and `models` (the default account resolver and its link and state
59
+ tables), `authorization` (the default authorization context provider), and
60
+ `auth.drf` (session and bearer authentication, permission-key and
61
+ resource-policy hooks, serializers and the management viewsets).
62
+ - **`drf`** — DRF integration outside the auth app: `drf.views` (base view
63
+ classes, mixins, `PermissionByMethodMixin`), `drf.routers`
64
+ (`CustomMethodRouter`, AIP-136 colon custom methods), `drf.transfer`
65
+ (`transfer` extra: tabular export/import, batch create/delete),
66
+ `drf.serializers` (base serializer, custom fields), `drf.exceptions` (the
67
+ RFC 9457 problem handler and the legacy handler), `drf.pagination` (AIP-158
68
+ cursor pagination), `drf.idempotency`, `drf.concurrency`, `drf.casing`
69
+ (camelCase renderer/parser) and `drf.openapi` (drf-spectacular; `openapi`
70
+ extra).
71
+ - **`tracing`** (`otel` extra) — `instrument()`: OpenTelemetry instrumentation
72
+ for Django, called once before Django loads.
73
+ - **`messaging`** — transactional outbox/inbox: abstract models,
74
+ `make_outbox_relay`, `process_event` (bus and handler registry come from
75
+ `rn_forge.commons.integration.messaging`).
76
+ - **`celery`** (`celery` extra) — `make_app` and `RETRYABLE_TASK_KWARGS`.
77
+ - **`settings`** — `rn_forge_django_settings`: a typed, frozen-dataclass
78
+ settings facade built from the Django `RN_FORGE_DJANGO` setting dict,
79
+ auto-reloaded on `override_settings`/`setting_changed`.
80
+ - **`fixtures`** — Builds Django JSON fixtures from Excel workbooks (requires
81
+ the `fixtures` extra).
82
+ - **`urls`** / **`views`** — Reusable standalone views (including the
83
+ `readiness_view` factory and `debug_request`) and URLconf; `utils` carries
84
+ the `require_settings`/`require_environment` startup guards.
85
+
86
+ The HTTP wire semantics — problem bodies, preconditions, pagination tokens,
87
+ idempotency keys, readiness reports, the auth contract — are `rn-forge-web`'s.
88
+ Everything here that touches them is an adapter, and `tests/test_conformance.py`
89
+ drives the shared conformance table through a Django application wired from
90
+ them.
91
+
92
+ ## Dependencies and package behavior
93
+
94
+ - **`rn-forge-web`** is a base dependency: five modules are adapters over it.
95
+ - **`rn-forge-auth`** is a base dependency: `auth` binds its login flows,
96
+ stores, `Principal`, `Requirement` and authorization contracts to Django and
97
+ DRF.
98
+ - **`drf-spectacular`** (`openapi` extra) supplies the OpenAPI schema
99
+ integration.
100
+ - **`drf.casing`** supplies the camelCase renderer and parser.
101
+ - **`oidc` extra** — JWKS verification is `rn-forge-auth[oidc]` (PyJWT);
102
+ `auth.drf.oidc` only binds it to DRF.
103
+ - **`celery` extra** — supplies the Celery app factory.
104
+ - **Migrations.** The auth app has one, for the external-account link and
105
+ account-state tables. `SequenceGenerator`'s counter is abstract and adds no
106
+ table.
107
+
108
+ ## Configuration
109
+
110
+ Settings are read from a single `RN_FORGE_DJANGO` dict in your Django settings
111
+ module, e.g.:
112
+
113
+ ```python
114
+ RN_FORGE_DJANGO = {
115
+ "AUTH": {"PROBLEM_TYPE_BASE": "https://errors.example.com/"},
116
+ "DRF": {
117
+ "TRANSFER": {"MAX_ROWS": 10_000},
118
+ "PAGINATION": {"PAGE_SIZE": 50, "MAX_PAGE_SIZE": 200},
119
+ "CASING": {"ENABLED": True},
120
+ },
121
+ }
122
+ ```
123
+
124
+ To use the bundled auth app, add `"rn_forge.django.auth"` to `INSTALLED_APPS`.
125
+
126
+ ## Development
127
+
128
+ From the repo root or this directory:
129
+
130
+ ```bash
131
+ uv run pytest packages/rn-forge-django # all tests
132
+ uv run pytest packages/rn-forge-django -m unit # fast isolated tests
133
+ uv run pytest packages/rn-forge-django -m integration # database-backed tests
134
+ uv run ruff check packages/rn-forge-django
135
+ uv run pyright
136
+ ```
137
+
138
+ Tests configure Django directly in
139
+ [`tests/conftest.py`](https://github.com/rn-forge/pykit/blob/main/packages/rn-forge-django/tests/conftest.py)
140
+ (sqlite in-memory database) — there is no separate Django settings module.
141
+ Test-only models and their tables follow the convention in that file's
142
+ docstring.
@@ -0,0 +1,141 @@
1
+ [project]
2
+ name = "rn-forge-django"
3
+ version = "0.6.0"
4
+ description = "Opinionated Django/DRF integration layer built on rn-forge-commons and rn-forge-web"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ classifiers = [
9
+ "Development Status :: 3 - Alpha",
10
+ "Intended Audience :: Developers",
11
+ "Framework :: Django",
12
+ "Operating System :: OS Independent",
13
+ "Programming Language :: Python :: 3",
14
+ "Programming Language :: Python :: 3 :: Only",
15
+ "Programming Language :: Python :: 3.14",
16
+ "Typing :: Typed",
17
+ ]
18
+ requires-python = ">=3.14"
19
+ dependencies = [
20
+ "django>=6.0.7",
21
+ "rn-forge-auth>=0.1.0,<0.2",
22
+ "rn-forge-commons>=0.8.0,<0.9",
23
+ "rn-forge-web>=0.3.0,<0.4",
24
+ ]
25
+
26
+ [[project.authors]]
27
+ name = "Rohit Narayanan"
28
+ email = "rohit.nn@gmail.com"
29
+
30
+ [project.optional-dependencies]
31
+ drf = ["djangorestframework>=3.17.1"]
32
+ transfer = [
33
+ "djangorestframework>=3.17.1",
34
+ "django-import-export>=4.4.1",
35
+ "rn-forge-data>=0.1.1,<0.2",
36
+ ]
37
+ fixtures = ["rn-forge-data[pandas]>=0.1.1,<0.2"]
38
+ oidc = [
39
+ "djangorestframework>=3.17.1",
40
+ "rn-forge-auth[oidc]>=0.1.0,<0.2",
41
+ ]
42
+ redis = ["rn-forge-auth[redis]>=0.1.0,<0.2"]
43
+ celery = ["celery>=5.6.3"]
44
+ openapi = [
45
+ "djangorestframework>=3.17.1",
46
+ "drf-spectacular>=0.30.0",
47
+ ]
48
+ security = ["rn-forge-web[security]>=0.3.0,<0.4"]
49
+ cors = ["django-cors-headers>=4.9.0"]
50
+ otel = ["opentelemetry-instrumentation-django>=0.65b0"]
51
+ all = [
52
+ "celery>=5.6.3",
53
+ "django-cors-headers>=4.9.0",
54
+ "django-import-export>=4.4.1",
55
+ "djangorestframework>=3.17.1",
56
+ "drf-spectacular>=0.30.0",
57
+ "opentelemetry-instrumentation-django>=0.65b0",
58
+ "rn-forge-auth[oidc,redis]>=0.1.0,<0.2",
59
+ "rn-forge-data[pandas]>=0.1.1,<0.2",
60
+ "rn-forge-web[security]>=0.3.0,<0.4",
61
+ ]
62
+
63
+ [project.urls]
64
+ Documentation = "https://rn-forge.github.io/pykit/packages/rn-forge-django/latest/"
65
+ Source = "https://github.com/rn-forge/pykit/tree/main/packages/rn-forge-django"
66
+ Changelog = "https://github.com/rn-forge/pykit/blob/main/packages/rn-forge-django/CHANGELOG.md"
67
+ Issues = "https://github.com/rn-forge/pykit/issues"
68
+
69
+ [build-system]
70
+ requires = ["uv_build>=0.11.28,<0.12.0"]
71
+ build-backend = "uv_build"
72
+
73
+ [tool.uv.build-backend]
74
+ module-name = "rn_forge.django"
75
+
76
+ [tool.uv.sources.rn-forge-auth]
77
+ workspace = true
78
+
79
+ [tool.uv.sources.rn-forge-commons]
80
+ workspace = true
81
+
82
+ [tool.uv.sources.rn-forge-data]
83
+ workspace = true
84
+
85
+ [tool.uv.sources.rn-forge-django]
86
+ workspace = true
87
+
88
+ [tool.uv.sources.rn-forge-web]
89
+ workspace = true
90
+
91
+ [tool.workspace-ci.postgres]
92
+ env = "RN_FORGE_DJANGO_TEST_DATABASE_URL"
93
+
94
+ [tool.workspace-ci.smoke]
95
+ setup = "tests/smoke_setup.py"
96
+ modules = [
97
+ "rn_forge.django",
98
+ "rn_forge.django.models",
99
+ ]
100
+
101
+ [tool.workspace-ci.smoke.extras]
102
+ drf = [
103
+ "rn_forge.django.drf",
104
+ "rn_forge.django.drf.views",
105
+ "rn_forge.django.auth.drf",
106
+ ]
107
+ fixtures = ["rn_forge.django.fixtures"]
108
+ transfer = ["rn_forge.django.drf.transfer"]
109
+ oidc = ["rn_forge.django.auth.drf.oidc"]
110
+ celery = ["rn_forge.django.celery"]
111
+ openapi = ["rn_forge.django.drf.openapi"]
112
+
113
+ [tool.pytest.ini_options]
114
+ addopts = "-ra --import-mode=importlib -m 'not scaffold'"
115
+ markers = [
116
+ "unit: fast isolated tests",
117
+ "integration: tests that exercise database-backed behavior",
118
+ "scaffold: installs built wheels into a scaffolded application (slow)",
119
+ "security_control: demonstrates the security control with the given rn_forge.auth.conformance case ID",
120
+ ]
121
+
122
+ [dependency-groups]
123
+ dev = [
124
+ "assertpy>=1.1",
125
+ "django-stubs>=6.0.7",
126
+ "opentelemetry-sdk>=1.44",
127
+ "psycopg[binary]>=3.3.5",
128
+ "pyright>=1.1.411",
129
+ "pytest>=9.1.1",
130
+ "pytest-cov>=7.1.0",
131
+ "pytest-django>=4.12.0",
132
+ "pytest-randomly>=4.1.0",
133
+ "rn-forge-django[all]",
134
+ "ruff>=0.15.21",
135
+ ]
136
+ docs = [
137
+ "mkdocs>=1.6.1",
138
+ "mkdocs-material>=9.7.6",
139
+ "mkdocstrings[python]>=1.0.6",
140
+ "rn-forge-django[all]",
141
+ ]
@@ -0,0 +1,147 @@
1
+ [project]
2
+ name = "rn-forge-django"
3
+ version = "0.6.0"
4
+ description = "Opinionated Django/DRF integration layer built on rn-forge-commons and rn-forge-web"
5
+ readme = "README.md"
6
+ authors = [{ name = "Rohit Narayanan", email = "rohit.nn@gmail.com" }]
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ classifiers = [
10
+ "Development Status :: 3 - Alpha",
11
+ "Intended Audience :: Developers",
12
+ "Framework :: Django",
13
+ "Operating System :: OS Independent",
14
+ "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python :: 3 :: Only",
16
+ "Programming Language :: Python :: 3.14",
17
+ "Typing :: Typed",
18
+ ]
19
+ requires-python = ">=3.14"
20
+ dependencies = [
21
+ "django>=6.0.7",
22
+ # Internal requirements are version ranges (ADR-0004).
23
+ "rn-forge-auth>=0.1.0,<0.2",
24
+ "rn-forge-commons>=0.8.0,<0.9",
25
+ "rn-forge-web>=0.3.0,<0.4",
26
+ ]
27
+
28
+ [project.optional-dependencies]
29
+ drf = ["djangorestframework>=3.17.1"]
30
+ # `rn_forge.django.drf.transfer` only: tabular export and import, batch create
31
+ # and delete. `write_xlsx` comes from rn-forge-data, which brings openpyxl.
32
+ transfer = [
33
+ "djangorestframework>=3.17.1",
34
+ "django-import-export>=4.4.1",
35
+ "rn-forge-data>=0.1.1,<0.2",
36
+ ]
37
+ # `fixtures.py` reads workbooks through `ExcelAdapter`, which needs pandas.
38
+ fixtures = [
39
+ "rn-forge-data[pandas]>=0.1.1,<0.2",
40
+ ]
41
+ # JWKS bearer auth for externally issued tokens. The authenticator itself is
42
+ # `rn_forge.auth.oidc`.
43
+ oidc = [
44
+ "djangorestframework>=3.17.1",
45
+ "rn-forge-auth[oidc]>=0.1.0,<0.2",
46
+ ]
47
+ # The Redis client for Django's Redis cache backend, which holds login
48
+ # transactions, replay records and revoked session IDs in production.
49
+ redis = ["rn-forge-auth[redis]>=0.1.0,<0.2"]
50
+ celery = ["celery>=5.6.3"]
51
+ # drf-spectacular only. djangorestframework-camel-case was evaluated and not
52
+ # taken: its last release is 1.4.2 (2023-02), with classifiers stopping at
53
+ # Python 3.10 — casing lives in `rn_forge.django.drf.casing` instead.
54
+ openapi = [
55
+ "djangorestframework>=3.17.1",
56
+ "drf-spectacular>=0.30.0",
57
+ ]
58
+ # `rn_forge.django.security` only, for the OWASP header preset
59
+ # (`rn_forge.web.security.API_SECURITY_HEADERS`, the `secure` library).
60
+ security = [
61
+ "rn-forge-web[security]>=0.3.0,<0.4",
62
+ ]
63
+ # `rn_forge.django.cors` only. The application still owns its origins;
64
+ # `cors_settings` only carries `CORS_EXPOSE_HEADERS`.
65
+ cors = ["django-cors-headers>=4.9.0"]
66
+ # `rn_forge.django.tracing` only, called once before Django loads. Separate
67
+ # from `drf`: tracing is not DRF-specific, and `uv sync --extra drf` must not
68
+ # pull it in.
69
+ otel = ["opentelemetry-instrumentation-django>=0.65b0"]
70
+ all = [
71
+ "celery>=5.6.3",
72
+ "django-cors-headers>=4.9.0",
73
+ "django-import-export>=4.4.1",
74
+ "djangorestframework>=3.17.1",
75
+ "drf-spectacular>=0.30.0",
76
+ "opentelemetry-instrumentation-django>=0.65b0",
77
+ "rn-forge-auth[oidc,redis]>=0.1.0,<0.2",
78
+ "rn-forge-data[pandas]>=0.1.1,<0.2",
79
+ "rn-forge-web[security]>=0.3.0,<0.4",
80
+ ]
81
+
82
+ [project.urls]
83
+ Documentation = "https://rn-forge.github.io/pykit/packages/rn-forge-django/latest/"
84
+ Source = "https://github.com/rn-forge/pykit/tree/main/packages/rn-forge-django"
85
+ Changelog = "https://github.com/rn-forge/pykit/blob/main/packages/rn-forge-django/CHANGELOG.md"
86
+ Issues = "https://github.com/rn-forge/pykit/issues"
87
+
88
+ [build-system]
89
+ requires = ["uv_build>=0.11.28,<0.12.0"]
90
+ build-backend = "uv_build"
91
+
92
+ [tool.uv.build-backend]
93
+ module-name = "rn_forge.django"
94
+
95
+ [tool.uv.sources]
96
+ rn-forge-auth = { workspace = true }
97
+ rn-forge-commons = { workspace = true }
98
+ rn-forge-data = { workspace = true }
99
+ rn-forge-django = { workspace = true }
100
+ rn-forge-web = { workspace = true }
101
+
102
+ [tool.workspace-ci.postgres]
103
+ # The `postgres`-marked tests read this DSN and skip without it.
104
+ env = "RN_FORGE_DJANGO_TEST_DATABASE_URL"
105
+
106
+ [tool.workspace-ci.smoke]
107
+ setup = "tests/smoke_setup.py"
108
+ modules = ["rn_forge.django", "rn_forge.django.models"]
109
+
110
+ [tool.workspace-ci.smoke.extras]
111
+ drf = ["rn_forge.django.drf", "rn_forge.django.drf.views", "rn_forge.django.auth.drf"]
112
+ fixtures = ["rn_forge.django.fixtures"]
113
+ transfer = ["rn_forge.django.drf.transfer"]
114
+ oidc = ["rn_forge.django.auth.drf.oidc"]
115
+ celery = ["rn_forge.django.celery"]
116
+ openapi = ["rn_forge.django.drf.openapi"]
117
+
118
+ [tool.pytest.ini_options]
119
+ addopts = "-ra --import-mode=importlib -m 'not scaffold'"
120
+ markers = [
121
+ "unit: fast isolated tests",
122
+ "integration: tests that exercise database-backed behavior",
123
+ "scaffold: installs built wheels into a scaffolded application (slow)",
124
+ "security_control: demonstrates the security control with the given rn_forge.auth.conformance case ID",
125
+ ]
126
+
127
+ [dependency-groups]
128
+ dev = [
129
+ "assertpy>=1.1",
130
+ "django-stubs>=6.0.7",
131
+ "opentelemetry-sdk>=1.44",
132
+ # The PostgreSQL test job (RN_FORGE_DJANGO_TEST_DATABASE_URL); see tests/conftest.py.
133
+ "psycopg[binary]>=3.3.5",
134
+ "pyright>=1.1.411",
135
+ "pytest>=9.1.1",
136
+ "pytest-cov>=7.1.0",
137
+ "pytest-django>=4.12.0",
138
+ "pytest-randomly>=4.1.0",
139
+ "rn-forge-django[all]",
140
+ "ruff>=0.15.21",
141
+ ]
142
+ docs = [
143
+ "mkdocs>=1.6.1",
144
+ "mkdocs-material>=9.7.6",
145
+ "mkdocstrings[python]>=1.0.6",
146
+ "rn-forge-django[all]",
147
+ ]
@@ -0,0 +1,3 @@
1
+ """rn-forge Django integration package."""
2
+
3
+ __all__: list[str] = []