Skip to main content

Django models, views, forms, and templates, built on schema.org Things the elioWay.

Project description

dna experimental

Dropping the pretense one thing is so different from another the elioWay

Django models, views, forms, and templates, built out of schema.org "Things", the elioWay.

Installing

pip install elio-dna

Seeing is believing

git clone https://gitlab.com/eliothing/dna.git
cd dna
virtualenv --python=python3 venv-dna
source venv-dna/bin/activate
pip install -r requirements/local.txt
./init_chromosomes.sh

Usage

Settings

Add the following required settings:

# settings.py
# The schema version you want your app to support
SCHEMA_VERSION = "3.9"
# List Persons and their Places (Contact Directory)
SITE_DNA = {"Person": {"ContactPoint", "Residence"}}
# List local MovieTheater in the area with Movies playing and Available Snacks
SITE_DNA = {"MovieTheater": {"Movie", "IndividualProduct"}}
# List Movies with actors/directors  and where playing.
SITE_DNA = {"Movies": {"MovieTheater", "Person"}}
# List Products and their Parts and Suppliers
SITE_DNA = {"Product": {"Part", "Organization"}}
DNA_DEPTH = 0

genome Management command

To help you find the right schema Thing, use our genome explorer: django-admin genome <class/property>

django-admin genome Thing
django-admin genome Person
django-admin genome isbn
django-admin genome description
django-admin genome image

Models

Add to your models file:

# /myapp/models.py
from django.conf import settings
from dna.models import every_model

every_model(
    settings.SCHEMA_PATH,
    ["CreativeWork", "Product"],
    0,
    "chromosomes",
)

Then.... Django as usual!

Mixins

Some helpful Mixins. Simply add alongside standard Django classes.

from dna.forms import every_form
from dna.views import (
    EveryCreateViewMixin,
    EveryDeleteViewMixin,
    EveryDetailViewMixin,
    EveryListViewMixin,
    EveryUpdateViewMixin,
)

Nutshell

django-admin livereload
django-admin runserver
black .

License

MIT Tim Bushell

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

elio-dna-1.0.2.tar.gz (21.7 kB view hashes)

Uploaded Source

Built Distribution

elio_dna-1.0.2-py3-none-any.whl (31.0 kB view hashes)

Uploaded Python 3

Supported by

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