我的django查询有问题。我是新的django程序员。
我有三种模式:
class Device(models.Model):
class Meta:
ordering = ('dev',)
verbose_name = _(u'Interface')
dev = models.CharField(_(u'Interface'), max_length=5, editable=True,
unique=True)
enable = models.BooleanField(_(u'Enabled'), default=True)
dhcp = models.BooleanField(_(u'DHCP'), default=False,
第二种模式:
class Config(models.Model):
class Meta:
ordering = ('ip_address',)
verbose_name = _(u'Network Configuration')
verbose_name_plural = _(u'Network Configurations')
device = models.ForeignKey(Device)
ip_address = models.IPAddressField(_(u'IP Address'), unique=True)
netmask = NetmaskAddressField(_(u'Netmask'))
description = models.CharField(_(u'Description'), blank=True, null=True,
max_length=255)
第三种模式:
class Dhcp(models.Model):
class Meta:
ordering = ('gateway',)
verbose_name = _(u'DHCP Configuration')
verbose_name_plural = _(u'DHCP Configurations')
config = models.ForeignKey(Config)
gateway = models.IPAddressField(_(u'Gateway'), null=True)
dns_primary = models.IPAddressField(_(u'DNS Primary'), null=True)
dns_second = models.IPAddressField(_(u'DNS Second'), blank=True)
leases_time = models.IntegerField()
nat = models.IPAddressField(_(u'NAT'), blank=True)
max_time = models.IntegerField()
现在,我的问题是:如何显示没有配置Dhcp的设备列表?
例如:我有Device
,它有三种配置。我需要检查Device
的所有配置,以确保没有DHCP配置,最后显示设备,但我不知道如何做到这一点。