【发布时间】:2020-02-20 11:23:54
【问题描述】:
在我的情况下,我需要在预期的字段数组中设计我的模型。
{field 1: string, field 2: [""], field 3: [""] }
到目前为止,我设计的模型如下:
class Collaborator(models.Model):
name = models.CharField(max_length=50, blank=True, null = True, )
class Responsibility(models.Model):
name = models.CharField(max_length=50, blank=True, null = True, )
class Class1(models.Model):
field 1 = models.CharField(max_length=50, blank=True, null = True, )
field 2 = models.ManyToManyField(Responsibility, related_name='res_cards', blank=True,null=True )
field 3 = models.ManyToManyField(Collaborator, related_name='col_cards', blank=True, null=True )
所以我期望获取数组中的所有字段而不是定义新模型
【问题讨论】:
-
请不要在变量名中使用空格。
标签: mysql django django-models django-rest-framework django-admin