嘿朋友,我是 django 模型的新手。我的问题是,我有五个表属性,例如 .
Rulno (integer)
From (IpAddressfield )
To(IpAddressfield )
Priority (integer)
Cisp(CharField)
对于单个 Ruleno,它们可以是多个 Priority 和 Cisp。所以我正在编写类似的模型。
class Ruleinfo(models.Model):
rule = models.IntegerField(null=False)
From = models.IPAddressField(null=True)
to = models.IPAddressField(null=True)
priority = models.ForeignKey('Priority',related_name = 'priority1')
Cisp =models.ForeignKey('Priority',related_name = 'cisp1')
def __unicode__(self):
return u'%s' %(self.rule)
class Priority(models.Model):
priority = models.IntegerField(null = True)
Ruleno = models.ForeignKey('Ruleinfo')
CISP = models.IntegerField(null = True)
def __unicode__(self):
return u'%s ' % (self.priority)
我想知道,上面的模型能满足我的要求吗?.
或者让我知道是否有其他选择。?