Hi,
I have the following model:
class MerchantFormFields(models.Model):
merchant_form = models.ForeignKey(MerchantForms)
label = models.CharField(max_length=50)
field_type = models.ForeignKey(FieldTypes)
required = models.BooleanField()
dependency = models.BooleanField()
order = models.IntegerField()
attributes = JSONField()
and use the following method to query:
def get_form_fields(self, dependency=None, order='order'):
self.get_merchant_form()
filter = {}
filter['merchant_form'] = self.merchant_form
if dependency is not None:
filter['dependency'] = dependency
return
MerchantFormFields.objects.filter(**filter).order_by(order)
No matter if I specify False/True/0/1 I always get all the fields
associated with the merchant_form and not the dependency field. If I
print the filter before the query I can see the dependency filter is
set:
When dependency is False:
filter: {'merchant_form': <MerchantForms: MerchantForms object>,
'dependancy': False}
When dependency is True
filter: {'merchant_form': <MerchantForms: MerchantForms object>,
'dependancy': True}
Even if I look at the query formulated:
{
'time': '0.109',
'sql': u'SELECT `merchant_merchantformfields`.`id`,
`merchant_merchantformfields`.`merchant_form_id`,
`merchant_merchantformfields`.`label`,
`merchant_merchantformfields`.`field_type_id`,
`merchant_merchantformfields`.`required`,
`merchant_merchantformfields`.`dependancy`,
`merchant_merchantformfields`.`order`,
`merchant_merchantformfields`.`attributes` FROM
`merchant_merchantformfields` WHERE
(`merchant_merchantformfields`.`merchant_form_id` = 3 AND
`merchant_merchantformfields`.`dependancy` = 1 ) ORDER BY
`merchant_merchantformfields`.`order` ASC'
}
I can see the filter is correct. I've even run this query and have
seen the result I'm looking for but when I run it in my code, I get
all fields for the specified merchant_form...
I really don't know why this is.
Any help is greatly appreciated.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.