from django.db import models # Create your models here. class Nomenclature(models.Model): code = models.CharField(max_length=50, unique=True) name = models.CharField(max_length=255) applies_to = models.CharField( max_length=50, choices=[("vehicle", "Vehicle"), ("container", "Container")] ) class NomenclatureField(models.Model): TEXT = "text" NUMBER = "number" BOOL = "bool" CHOICE = "choice" FIELD_TYPES = [ (TEXT, "Text"), (NUMBER, "Number"), (BOOL, "Boolean"), (CHOICE, "Choice"), ] nomenclature = models.ForeignKey( Nomenclature, on_delete=models.CASCADE ) key = models.CharField(max_length=50) field_type = models.CharField(max_length=20, choices=FIELD_TYPES)