私はやや奇妙なシナリオを持っています。プロパティ管理ソフトウェアからアクセスできる読み取り専用データベースを使用しています。これらにより、ユーザーはソフトウェアでフィールドを定義できます。ただし、データベース内の特定のフィールドとして表示されません。データベースには、それらに関連する 2 つのテーブルpropuserdefined
とpropuserdefinedvalues
. プロパティに関連付けられた値を含むpropuserdefined
フィールド (ID、名前、説明) に関するすべての情報が含まれます。、、およびpropuserdiefinedvalues
があります。私の質問はこれです。プロパティ ステートメントの for プロパティとequals 49 のwhere に等しい値にアクセスする必要があります。これを行うにはどうすればよいですか? テンプレートタグ付きですか? propid
userdefinedid
value
propuserdefinedvalues
propid
propid
userdefinedid
よろしくお願いします。
ブランドン
これが私のモデルです。
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'