Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bhch committed Sep 17, 2024
1 parent 54926ba commit d4c1f80
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 1 deletion.
52 changes: 51 additions & 1 deletion docs/guide/arrayfield.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,54 @@ It is a subclass of Django's ``ArrayField`` and the usage api is exactly the sam
class MyModel(models.Model):
items = ArrayField(models.CharField(max_length=50), size=10)
items = ArrayField(models.CharField(max_length=50), size=10)
.. _arrayfield custom schema:

Custom schema for ``ArrayField``
--------------------------------

.. versionadded:: 2.23

Overriding the schema is useful when you want to render custom widgets on the
browser.

However, it is your responsibility to write the correct schema as mismatches in
data structure may cause validation errors while saving data.

Example:

.. code:: python
from django_jsonform.models.fields import ArrayField
class MyModel(...):
ITEMS_SCHEMA = {
"type": "array",
"items": {
"type": "string",
"maxLength": 50
},
"maxItems": 10
}
items = ArrayField(models.CharField(max_length=50), size=10, schema=ITEMS_SCHEMA)
.. _arrayfield custom widget:

Overriding the widget for ``ArrayField``
----------------------------------------

.. versionadded:: 2.23

The default widget for the ``ArrayField`` can be overridden to provide custom schema
and do some other stuff.

If you only need to provide custom schema, then it's better to just use the ``schema``
argument as described in the :ref:`previous section <arrayfield custom schema>`.

Overriding the widget for ``ArrayField`` works the same way as for the ``JSONField``.
For usage examples, see: :class:`~django_jsonform.widgets.JSONFormWidget`.
1 change: 1 addition & 0 deletions docs/releases/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Release notes
.. toctree::
:maxdepth: 2

v2.23.0
v2.22.0
v2.21.5
v2.21.4
Expand Down
43 changes: 43 additions & 0 deletions docs/releases/v2.23.0.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
django-jsonform 2.23.0 release notes
====================================


Sep 17, 2024
------------

This release fixes some bugs and brings a couple of new features.


New features
^^^^^^^^^^^^

- :issue:`72`: ``ArrayField`` now accepts a custom schema. More in docs. :ref:`See usage docs <arrayfield custom schema>`.

- :pr:`162`: ``ArrayField``'s widget can be overridden now (by Willard Nilges). :ref:`See usage docs <arrayfield custom widget>`.


Bugfixes
^^^^^^^^

- :issue:`172`: Fixed a bug that prevented using ``JSONField`` as an item of the ``ArrayField``.

- :pr:`175`: Fixed a bug which caused issues when choices had whitespace in them (by Kyle Perik).

- :issue:`165`: Excluded the tests from PyPI wheel package (by Bruno Alla in PR :pr:`176`).


Browser side improvements
^^^^^^^^^^^^^^^^^^^^^^^^^

- Fixed (suppressed for the time being) buggy validation of ``oneOf``/``anyOf`` within an object.

- Fixed crashes when using ``oneOf``.

- Fixed number input validation. Some browsers need ``step=any`` for decimal values.


react-json-form (JavaScript)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

`react-json-form <https://github.com/bhch/react-json-form>`_ has been updated
to version 2.14.2.

0 comments on commit d4c1f80

Please sign in to comment.