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.3.1.tar.gz (19.7 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.3.1-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for semandjic-0.3.1.tar.gz
Algorithm Hash digest
SHA256 550a811415bc997a09ef17e5f80f9545c950d0e86f39878630c2f65f41b17022
MD5 9284c7204d6dedffcb6461faa0ffe8af
BLAKE2b-256 ff9d4d41b18d9a28da51c96c9a2a0d0136ffdf236674c2e1b0ff07e2a0a096aa

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for semandjic-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 36d5c785ff418d28c5db129d3946e7863b02435caa3f6232162a16102a14a465
MD5 41c82cd6f9d7b6fac5fbb76d07e7ac4a
BLAKE2b-256 9cfe6ddb0fee604df3a88651db17b0f711e211b8d799685c0bae699a8df11367

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