我有一个有点奇怪的场景。我正在使用可以通过我的物业管理软件访问的只读数据库。它们允许用户在软件中定义字段。但是,它们不会显示为数据库中的特定字段。该数据库有 2 个与它们相关的表propuserdefined
和propuserdefinedvalues
. 包含有关字段的propuserdefined
所有信息(id、名称、描述),propuserdiefinedvalues
包含与属性关联的值。它有propid
、userdefinedid
和value
。我的问题是,我需要访问propuserdefinedvalues
where的值propid
等于propid
我的 for property in properties 语句中的值和userdefinedid
等于 49。我该怎么做?是否带有模板标签?
在此先感谢您的帮助。
布兰登
这是我的模型。
class Propuserdefined(models.Model):
userdefinedid = models.IntegerField(primary_key=True)
name = models.CharField(max_length=50L, blank=True)
type = models.IntegerField()
userid = models.IntegerField(null=True, blank=True)
updated = models.DateTimeField(null=True, blank=True)
datecreated = models.DateTimeField(null=True, blank=True)
combolist = models.TextField(blank=True)
class Meta:
db_table = 'propuserdefined'
class Propuserdefinedvalues(models.Model):
userdefinedid = models.IntegerField()
propid = models.IntegerField()
value = models.TextField(blank=True)
userid = models.IntegerField(null=True, blank=True)
updated = models.DateTimeField(null=True, blank=True)
datecreated = models.DateTimeField(null=True, blank=True)
class Meta:
db_table = 'propuserdefinedvalues'
class Property(models.Model):
propid = models.IntegerField(primary_key=True)
name = models.CharField(max_length=35L, blank=True)
shortname = models.CharField(max_length=6L, blank=True)
street1 = models.CharField(max_length=50L, blank=True)
street2 = models.CharField(max_length=50L, blank=True)
city = models.CharField(max_length=50L, blank=True)
state = models.CharField(max_length=2L, blank=True)
zip = models.CharField(max_length=50L, blank=True)
phone = models.CharField(max_length=21L, blank=True)
fax = models.CharField(max_length=50L, blank=True)
email = models.CharField(max_length=255L, blank=True)
manager = models.CharField(max_length=25L, blank=True)
billname1 = models.CharField(max_length=35L, blank=True)
billname2 = models.CharField(max_length=35L, blank=True)
billstreet1 = models.CharField(max_length=50L, blank=True)
billstreet2 = models.CharField(max_length=50L, blank=True)
billcity = models.CharField(max_length=50L, blank=True)
billstate = models.CharField(max_length=2L, blank=True)
billzip = models.CharField(max_length=50L, blank=True)
proptaxid = models.CharField(max_length=35L, blank=True)
rentchargetype = models.CharField(max_length=20L, blank=True)
lastpostdate = models.DateField(null=True, blank=True)
lastweeklypostdate = models.DateField(null=True, blank=True)
comments = models.CharField(max_length=25L, blank=True)
enablespeciallatecharge = models.IntegerField(null=True, blank=True)
fixedlatecharge = models.IntegerField(null=True, blank=True)
fixedlateamount = models.FloatField(null=True, blank=True)
fixedlaterentonly = models.IntegerField(null=True, blank=True)
percentlate = models.IntegerField(null=True, blank=True)
percentlateamount = models.FloatField(null=True, blank=True)
percentlatefullcharge = models.IntegerField(null=True, blank=True)
percentlaterentonly = models.IntegerField(null=True, blank=True)
perdaylate = models.IntegerField(null=True, blank=True)
perdaylateamount = models.FloatField(null=True, blank=True)
perdaylategrace = models.IntegerField(null=True, blank=True)
perdaylategracenum = models.IntegerField(null=True, blank=True)
perdatelatelimitamount = models.FloatField()
perdaylategracenonretro = models.IntegerField()
perdaylategraceexclweekends = models.IntegerField()
perdaylategraceexclholidays = models.IntegerField()
datecreated = models.DateTimeField(null=True, blank=True)
updated = models.DateTimeField(null=True, blank=True)
userid = models.IntegerField(null=True, blank=True)
logofile = models.CharField(max_length=255L, blank=True)
merchantid = models.CharField(max_length=255L, blank=True)
epaybankid = models.IntegerField()
epaylimit = models.FloatField()
epayenabled = models.IntegerField()
achconveniencefeeenabled = models.IntegerField()
ccconveniencefeeenabled = models.IntegerField()
rwaachconvenciencefeeenabled = models.IntegerField()
rwaccconveniencefeeenabled = models.IntegerField()
epayislimited = models.IntegerField()
epayusedefaults = models.IntegerField()
achconveniencefee = models.FloatField(null=True, blank=True)
ccconveniencefee = models.FloatField(null=True, blank=True)
rwaachconveniencefee = models.FloatField(null=True, blank=True)
rwaccconveniencefee = models.FloatField(null=True, blank=True)
epaychargetype = models.IntegerField()
epayamounttype = models.IntegerField()
epaysetamount = models.FloatField()
epaycustlimit = models.FloatField()
sqft = models.IntegerField()
lateminbalance = models.FloatField(null=True, blank=True)
defaultbank = models.IntegerField()
postday = models.IntegerField(null=True, blank=True)
active = models.IntegerField(null=True, blank=True)
iscommercial = models.IntegerField(null=True, blank=True)
assignedissueuserid = models.IntegerField(null=True, blank=True)
altname = Propuserdefinedvalues.objects.filter(userdefinedid=49)
class Meta:
db_table = 'property'