User-defined typed JSON objects for Django, powered by django-structured-json-field
Project description
django-structured-metaobjects
User-defined, typed JSON objects for Django — built on top of
django-structured-json-field.
Editors define meta types in the admin (a list of typed field
definitions). Each MetaInstance then picks one of those types and the
admin form / REST API automatically adapts to the schema declared by the
chosen type.
Features
- Field kinds: primitives,
ref(single FK),queryset(list of FKs),group(nested object),list(repeating group), with optionaltranslated=Trueper-field. - Runtime Pydantic compiler with per-MetaType caching, invalidated on save.
- Admin form rebuilds the
datawidget for the selected meta type. - DRF
MetaTypeViewSet/MetaInstanceViewSetwithschema/action. - Typed access on
instance.obj.<field>returning the parsed Pydantic model — FK / queryset fields lazily resolve to real Django objects with structured-json-field's caching.
Install
pip install django-structured-metaobjects
Add to INSTALLED_APPS:
INSTALLED_APPS = [
# ...
"structured",
"structured_metaobjects",
]
Wire the REST endpoints into your router:
from rest_framework import routers
from structured_metaobjects.views import MetaTypeViewSet, MetaInstanceViewSet
router = routers.DefaultRouter()
router.register(r"meta-types", MetaTypeViewSet, "meta-types")
router.register(r"meta-instances", MetaInstanceViewSet, "meta-instances")
Field kinds
| kind | Python type built by the compiler | Notes |
|---|---|---|
string |
str |
|
text |
str |
Multi-line. |
integer |
int |
|
number |
float |
|
boolean |
bool |
|
date |
datetime.date |
|
datetime |
datetime.datetime |
|
ref |
<TargetModel> |
Requires target_model="app.Model". |
queryset |
List[<TargetModel>] |
Requires target_model="app.Model". |
group |
nested Pydantic model from children |
|
list |
List[<group model>] from children |
Setting translated=True wraps the field in Dict[str, T] so the value
is a per-language map.
Typed access
instance = MetaInstance.objects.get(pk=1)
obj = instance.obj # cached Pydantic instance
obj.title # typed string
obj.related_page # real Django model instance (lazy/cached)
obj.gallery # list of real Django model instances
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_structured_metaobjects-1.0.0.tar.gz.
File metadata
- Download URL: django_structured_metaobjects-1.0.0.tar.gz
- Upload date:
- Size: 18.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01c5dfd38345610a52d71bac61b8a6a6d37919443c50f15e62c9e68b36dd982e
|
|
| MD5 |
c6d314c04e696aff542127606ff38fd9
|
|
| BLAKE2b-256 |
191fd5e4f1e27f3333461821ac60f2bda10aa509290b20247cb9641d0c376cb9
|
Provenance
The following attestation bundles were made for django_structured_metaobjects-1.0.0.tar.gz:
Publisher:
cd.yml on bnznamco/django-structured-metaobjects
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_structured_metaobjects-1.0.0.tar.gz -
Subject digest:
01c5dfd38345610a52d71bac61b8a6a6d37919443c50f15e62c9e68b36dd982e - Sigstore transparency entry: 1271663988
- Sigstore integration time:
-
Permalink:
bnznamco/django-structured-metaobjects@cc2918b1bb65ea78d0fbf279895ab85d07019bc9 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/bnznamco
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@cc2918b1bb65ea78d0fbf279895ab85d07019bc9 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file django_structured_metaobjects-1.0.0-py2.py3-none-any.whl.
File metadata
- Download URL: django_structured_metaobjects-1.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 27.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47961d945953039adfd4f94993e489fc9546e87d1824c01a5b136ed1c7baf17e
|
|
| MD5 |
32de442cdf6fc32201f75368a69fbc99
|
|
| BLAKE2b-256 |
6dae013c106568f934c16d80ba29a4aff78bf1e89b1ab419c8e4ba0d0e262476
|
Provenance
The following attestation bundles were made for django_structured_metaobjects-1.0.0-py2.py3-none-any.whl:
Publisher:
cd.yml on bnznamco/django-structured-metaobjects
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_structured_metaobjects-1.0.0-py2.py3-none-any.whl -
Subject digest:
47961d945953039adfd4f94993e489fc9546e87d1824c01a5b136ed1c7baf17e - Sigstore transparency entry: 1271664052
- Sigstore integration time:
-
Permalink:
bnznamco/django-structured-metaobjects@cc2918b1bb65ea78d0fbf279895ab85d07019bc9 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/bnznamco
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@cc2918b1bb65ea78d0fbf279895ab85d07019bc9 -
Trigger Event:
workflow_dispatch
-
Statement type: