1. Abstract Dynamic Models

class dynamite.models.AbstractAttribute(*args, **kwargs)[source]

Bases: django.db.models.base.Model

This abstract model represents the table’s fields template.

You should inherit from this class when you want to add something to this template.

from django.db import models
from dynamite.models import AbstractSchema, AbstractAttribute
from dynamite.registry import register

class Survey(AbstractSchema):
    class Meta:
        verbose_name = 'survey'
        verbose_name_plural = 'surveys'

Note

You have to make a foreign key through the schema:

class Question(AbstractAttribute):
    rank = models.PositiveIntegerField(default=5)
    schema = models.ForeignKey(Survey)

    class Meta:
        ordering = ['rank']
        verbose_name = 'question'
        verbose_name_plural = 'questions'

Note

To activate this schema remember to register it in yourapp.models with:

register(
    schema = Survey,
    attribute = Question,
)

Note

At the moment an Attribute can be:
  • Short text
  • Long text
  • Number
  • Decimal number
class dynamite.models.AbstractEntity(*args, **kwargs)[source]

Bases: django.db.models.base.Model

This abstract model represents the Table.

You should inherit from this class when you want something in common in your schema. For example you want share uniqueness of primary keys

from django.db import models
from dynamite.models import AbstractSchema, AbstractEntity
from dynamite.registry import register

class Survey(AbstractSchema):
    class Meta:
        verbose_name = 'survey'
        verbose_name_plural = 'surveys'

class Response(AbstractEntity):
    name = models.CharFields(primary_key = True)
    class Meta:
        abstract = True
        verbose_name = 'response'
        verbose_name_plural = 'responses'

Note

To activate this schema remember to register it in yourapp.models with:

register(
    schema = Survey,
    entity = Response,
)
class dynamite.models.AbstractSchema(*args, **kwargs)[source]

Bases: django.db.models.base.Model

This abstract model represents the Tables container (As a Database).

You should inherit from this class when you want to start a dynamical model system.

from dynamite.models import AbstractSchema
from dynamite.registry import register

class Survey(AbstractSchema):
    class Meta:
        verbose_name = 'survey'
        verbose_name_plural = 'surveys'

Note

To activate this schema remember to register it in yourapp.models with:

register(
    schema = Survey,
)

Previous topic

django-dynamite’s docs

Next topic

2. Admin tools

This Page