Skip to main content

A Django app for semantic model relationships and nested forms

Project description

Semandjic

A Django app for handling nested forms and object trees with automatic relationship discovery.

Features

  • Automatic form generation for related models
  • Handles nested relationships recursively
  • Prevents circular references
  • Configurable depth and relationship handling
  • Support for forward and backward relations
  • Customizable field exclusion
  • Tree visualization of model relationships

Installation

pip install semandjic

Quick Start

  1. Add to INSTALLED_APPS:
INSTALLED_APPS = [
    ...,
    'semandjic',
]
  1. Configure settings (optional):
SEMANDJIC = {
    'FIELDS_TO_EXCLUDE': {'id', 'modified_at'},
    'MAX_DEPTH': 5,
    'MAX_RELATED_OBJECTS': 10,
}
  1. Use the methods directly from the classes and write your own semantic data flows:
from semandjic.forms import NestedForms

# Generate forms
classmap = NestedForms.build_classmap_from_prefix_and_model_class(
    prefix='someone',
    model_class='myapp.Person'
)

forms = NestedForms.get_nested_forms_from_classmap(classmap)

# Persist forms

forms, valid, objs = NestedForms.persist_nested_forms_and_objs(
    classmap,
    request.POST
)
if valid:
    for obj in objs:
        obj.save()

Also check for test_default_data_workflow in test_forms.py to see the simplicity of the API from schema to forms to related instances in a SQL Database using your own Applications Ontologies (models).

  1. Use the included urls and views
from django.urls import path

# including them
path('core/', include('semandjic.urls')),

# using them as you please
path('object/<str:model_class>/<int:pk>/', 
     ObjectTreeView.as_view(), 
     name='object-tree'),

Documentation

For more detailed documentation, visit our GitHub repository.

Development

To contribute:

# Clone the repository
git clone https://github.com/iSeeCI/semandjic.git
cd semandjic

# Create virtual environment
python -m venv venv
source venv/bin/activate  # or `venv\Scripts\activate` on Windows

# Install development dependencies
pip install -e ".[dev]"

# Run tests
python runtests.py

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

semandjic-0.2.0.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

semandjic-0.2.0-py3-none-any.whl (20.7 kB view details)

Uploaded Python 3

File details

Details for the file semandjic-0.2.0.tar.gz.

File metadata

  • Download URL: semandjic-0.2.0.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for semandjic-0.2.0.tar.gz
Algorithm Hash digest
SHA256 7bb99356af6531436621787244a67b259043f2a89b8f5a22e57482d5b15a978d
MD5 8b5b99cdc8712760818cd5b285ed0895
BLAKE2b-256 71f92796127ad9a45ce77ed896af4279147988102f38206d39ce94186fae3cba

See more details on using hashes here.

File details

Details for the file semandjic-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: semandjic-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 20.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for semandjic-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3d82ed31e830fbebcc81534276d3f017b0d67df0807236ce892799c75edc7172
MD5 26449ab68b310c2e243f9bbb77a771a9
BLAKE2b-256 27b96615737cad1467d674508b3b4d69cd66113293c3f4f94232d768ba31cb27

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page