Metadata-Version: 2.5
Name: django-jedminson
Version: 0.1.0
Summary: JSON Schema form field for Django admin, powered by Jedison
Project-URL: Repository, https://github.com/inueni/django-jedminson
Project-URL: Issues, https://github.com/inueni/django-jedminson/issues
Author: Frodx
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: Django :: 5.2
Classifier: Framework :: Django :: 6.0
Classifier: Framework :: Django :: 6.1
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.10
Requires-Dist: django>=5.2
Requires-Dist: jsonschema>=4.25.1
Description-Content-Type: text/markdown

# django-jedminson

Opinionated JSON Schema form field for Django admin, powered by
[Jedison](https://github.com/germanbisurgi/jedison).

For configuration that lives in a `JSONField`, Jedminson gives you an admin form
with familiar controls and collapsible fieldsets. Define the data with JSON Schema,
choose a layout if you need one, and let Python validate what gets submitted.

![An integration configuration rendered by Jedminson in Django admin](https://raw.githubusercontent.com/inueni/django-jedminson/0.1.0/docs/images/admin.png)

## Installation

Requires Python 3.10+ and Django 5.2+.

```bash
python -m pip install django-jedminson
```

Add `jedminson` to `INSTALLED_APPS` alongside your Django admin apps. Serve its
static files through your usual setup, including `collectstatic` for deployment.
JavaScript and CSS are included in the release archives; no frontend build is
needed to use the package.

## Quick start

Here's a configuration with a URL and an enabled flag. Start with a normal model
`JSONField` in your app's `models.py`:

```python
from django.db import models


class Integration(models.Model):
    name = models.CharField(max_length=100)
    config = models.JSONField(default=dict, blank=True)

    def __str__(self):
        return self.name
```

Give it a schema in `forms.py`:

```python
from jedminson.forms import JSONSchemaField, JedminsonModelForm

from .models import Integration


class IntegrationForm(JedminsonModelForm):
    config = JSONSchemaField(schema={
        'type': 'object',
        'properties': {
            'url': {'type': 'string', 'title': 'URL', 'minLength': 1},
            'enabled': {'type': 'boolean', 'title': 'Enabled', 'default': True},
        },
        'required': ['url'],
    })

    class Meta:
        model = Integration
        fields = ['name', 'config']
```

Then register the form in `admin.py`:

```python
from django.contrib import admin

from .forms import IntegrationForm
from .models import Integration


@admin.register(Integration)
class IntegrationAdmin(admin.ModelAdmin):
    form = IntegrationForm
```

Use `JedminsonModelForm` so the widget receives bound values and validation errors.
Keep `blank=True` on the model field so empty JSON containers reach schema
validation. Your schema decides whether they're valid; model constraints still
apply.

## Controlling the layout

`display` is optional. Leave it out and fields follow the schema's property order.
To group the two fields above, add this argument to `JSONSchemaField`:

```python
display=[{
    'type': 'fieldset',
    'title': 'Connection',
    'collapsible': 'open',
    'fields': [{'path': '/url'}, {'path': '/enabled'}],
}]
```

The schema describes the data and its validation. `display` controls where the
fields go, without changing that schema.

## Current scope

Version 0.1.0 is Beta and supports stock Django admin. It handles scalar fields,
objects, nested arrays and conditional fields.

Not every valid JSON Schema can be rendered. Avoid unusual property names for now:
Jedison has known path and HTML-ID collisions with names such as `a/b`, `a.b` and
empty strings, which can affect editing, error placement and focus.
