Код: Выделить всё
class Metric(models.Model):
name = CharField(null = True, blank = True, max_length = 200)
abbreviation = CharField(null = True, blank = True, max_length = 10)
def __str__(self):
try:
return self.name
except Exception as e:
return str(e)
class Test(models.Model):
name = CharField(null = True, blank = True, max_length = 200)
metrics = ManyToManyField(Metric, null = True, blank = True)
def __str__(self):
try:
return self.name
except Exception as e:
return str(e)
class TestVariable(models.Model):
independent_variable = ForeignKey(Variable, null = True, blank = True,on_delete = models.CASCADE, related_name = "independent_variables")
dependent_variable = ForeignKey(Variable, null = True, blank = True, on_delete = models.CASCADE, related_name = "dependent_variables")
test = ForeignKey(Test, null = True, blank = True, on_delete = models.CASCADE)
def __str__(self):
try:
return self.name
except Exception as e:
return str(e)
для Например, если бы я создал Метрику для стандартного отклонения, в TestVariable автоматически создалось бы поле для получения числового значения стандартного отклонения.
Подробнее здесь: https://stackoverflow.com/questions/783 ... d-creation