Models

Basic Model Setup

Because models that are passed to CDA might already exist, the only addition that is initially needed is a managed field to allow CDA to use the field

managed = models.BooleanField(default=True)

Model Fields

Once a model is managed, the fields that can be used to geneerate front-end content need to be specified. This is done primarily because not every field is relevant when generating content. for example, a User model might display a name field, and an Id, but not a password field (if explicitly defined).

def compatible_fields(self):
    l = [self.field1, self.field2, self.field3]
    return l

Model Types

The final step needed to complete the model setup is telling the CDA what kind of data to expect. For example a a Product model that only contains a name and stock data would not be suitable for a pie chart, while a model that tracks sales data over time would be well-suited to a line chart.

def type_flags():
    flags = ["table", "pieChart"]
    return flags

There are several different model types avaliable, listed below:

It is important to note that for the first 3 model types listed above, whatever the fields or types, the process will be applied to every instance of a given model, so if a Product model with 3 instances is made into a table that table will display 3 rows, one per model instance.