Lepta Technologies | Documentation

Create a Model

Define the model

1. Create a class that inherits from spinalcord.models.Model

2. Add fields (as properties) to the class

3. The class must implement the get_fields method

3.1. This method should return a list of all the fields you added to the class in step 2

Example

from spinalcord import fields
from spinalcord.models import Model

class Coordinate(Model):
    x = fields.DoubleField("x")
    y = fields.DoubleField("y")

    def get_fields(self):
        return [self.x, self.y]