You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Updated dependencies, added support for Python 3.11 and Django 4.1, dropped support for Django 2.
* Flake 8 doesn't support Python < 3.8.
* CI action to create GH release.
* Updated example app, docker-compose, Dockerfile, added black, some small fixes.
* Dropped Python 3.7 support.
Copy file name to clipboardExpand all lines: README.rst
+23-20Lines changed: 23 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,24 +17,25 @@ in Django projects.
17
17
Motivation
18
18
----------
19
19
20
-
`JSON types <https://www.postgresql.org/docs/10/datatype-json.html>`_ is a cool feature of
21
-
Postgres that allows combining both relational and non-relational approaches to storing data. In most cases
22
-
it leads to a simpler database design.
23
-
24
-
The `JSONField <https://docs.djangoproject.com/en/3.1/ref/contrib/postgres/fields/#jsonfield>`_ in Django provides a
25
-
nice way of using **json** and **jsonb** Postgres types in the model classes. ORM can even allow you to perform queries
26
-
against the data stored inside the JSON structure. Moreover, it is possible to use
27
-
`GIN indexes <https://www.postgresql.org/docs/12/datatype-json.html#JSON-INDEXING>`_ with **jsonb** types in Postgres, what
28
-
makes it a useful tool in the application design and opens a wide range of possibilities such as polymorphic behaviour,
29
-
storing complex hierarchies and lists of related entities, etc.
30
-
31
-
However, the main limitation of JSONField in Django is a lack of good support of UI for JSON structures as defining JSON objects
20
+
`JSON types <https://www.postgresql.org/docs/10/datatype-json.html>`_ in Postgres allow combining both relational
21
+
and non-relational approaches to storing data. That can lead to a simpler database design in the most cases.
22
+
23
+
Django provides ORM support for JSON types in Postgres and other databases via the
24
+
`JSONField model field <https://docs.djangoproject.com/en/4.1/ref/models/fields/#django.db.models.JSONField>`_. Also the
25
+
`JSONField form field <https://docs.djangoproject.com/en/4.1/ref/forms/fields/#jsonfield>`_ allows basic support of JSON in forms.
26
+
Django ORM even `allows querying <https://docs.djangoproject.com/en/4.1/topics/db/queries/#querying-jsonfield>`_ against the data stored
27
+
inside the JSON structures. Moreover, it is possible to improve performance of these queries using
28
+
`GIN indexes <https://www.postgresql.org/docs/15/datatype-json.html#JSON-INDEXING>`_ with **jsonb** types
29
+
`in Django <https://docs.djangoproject.com/en/4.1/ref/contrib/postgres/indexes/#ginindex>`_, which
30
+
makes opens up a wide range of possibilities for simplifying application design, such as polymorphic collections, storing complex hierarchies in JSON, lists of related entities, etc.
31
+
32
+
However, the main limitation of JSONField in Django is the lack of good support of UI for JSON structures as defining JSON objects
32
33
inside the textarea inputs is not practical for most use cases. django-reactive tries to address this problem by offering an
33
34
integration between JSONField and the awesome `react-jsonschema-form <https://github.com/mozilla-services/react-jsonschema-form>`_
34
35
(RJSF) JavaScript library.
35
36
36
37
django-reactive also uses Python `jsonschema <https://github.com/Julian/jsonschema>` library for backend validation. Such integration
37
-
can significantly reduce the amount of work you need to contribute into building custom forms for JSONField types.
38
+
can significantly reduce the amount of work needed for building custom forms for JSONField types.
38
39
39
40
In most cases it only requires a JSON schema configuration for such field and optionally a UI schema
40
41
to modify some representation parameters.
@@ -142,7 +143,7 @@ Running the example
142
143
143
144
Build the docker image for the Django application in `example/`:
144
145
145
-
* Run `docker-compose up -d`
146
+
* Run `dockercompose up -d`
146
147
147
148
This will automatically create the database, run migrations, import the default superuser, and run the Django development server on `http://127.0.0.1:8000`.
148
149
@@ -254,19 +255,21 @@ Features
254
255
* React, RJSF and other JS assets are bundled with the package.
255
256
* Integration with default Django admin theme.
256
257
* Backend and frontend validation.
257
-
* Configurable static media assets
258
-
* Dynamic schema mutation in widget renders
258
+
* Configurable static media assets.
259
+
* Dynamic schema mutation in widget renders.
259
260
260
261
Limitations
261
262
-----------
262
263
263
264
* `Additional properties <https://github.com/mozilla-services/react-jsonschema-form#expandable-option>`_ ( a feature of RJSF) is not supported.
264
265
265
-
To implement this behaviour you can define an array schema with one property serving as a key of the object and do
266
-
transformation in your JSON class. An example will be provided later.
266
+
To implement this behavior you can define an array schema with one property serving as a key of the object and do
267
+
transformation in the Django form.
268
+
269
+
* An outdated version (1.8) of RJSF is used in this project. Not all features of RJSF 1.8 are compatible with JSON Schema 4.0. Please, refer to the documentation if any issues.
267
270
268
271
Future development
269
272
------------------
270
273
271
-
* Display description as tooltips
272
-
* Polish styles and HTML generated by **RJSF**
274
+
* At the moment there is no plans to add new features or support a newer version of RJSF.
275
+
* Probably, it is a good idea to replace RJSF with a more Django-friendly solution. It would require significant development effort though, that's why the idea is put on back burner at the moment.
0 commit comments