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.0.tar.gz (19.1 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.0-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for semandjic-0.3.0.tar.gz
Algorithm Hash digest
SHA256 d9985d9a46828033fac4efc98cd51de5f2739d78de7ffa46279a1ed0cf483d51
MD5 cdf31c8c046a3a5d28be55463b047de3
BLAKE2b-256 4f9cc7b39b590c39757c7fd7fbec1fd97107a57b0aedad7e168a0275d153b797

See more details on using hashes here.

File details

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

File metadata

  • Download URL: semandjic-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 20.8 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4d45878b56755472cf04a7a28a227a9938fe5b93ca036578663e0ca2ca7fc5ce
MD5 f52a7dc131d9b097b8ce1256f4a5531b
BLAKE2b-256 e44100512da6dad5c767735231c6cd6558a446251d57d6671cc3000dda6a1706

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