class Service(models.Model):
service_name = models.CharField(max_length=200)
service_text = models.CharField(,max_length=200)
access_port = models.CharField(max_length=200)
def __str__(self):
return self.service_name
class ServiceTag(models.Model):
service = models.ForeignKey(Service)
tag_version = models.CharField(max_length=200)
def __str__(self):
return self.service.service_name+'_'+self.tag_version
class SettingItem(models.Model):
ipservice = models.ForeignKey(Service)
ipenvironment = models.OneToOneField('Environment')
host_ip = models.CharField(max_length=200)
def __str__(self):
return self.host_ip
class Environment(models.Model):
project = models.ForeignKey(Project)
environment_name = models.CharField(max_length=200)
servicetag = models.ManyToManyField(ServiceTag)
def __str__(self):
return self.project.project_name+'-'+self.environment_name
请问已知了Environment和ServicreTag对象怎么获得对应的SettingItem对象啊?