Merge pull request #49 from radalin/master

fix generic entity filter problem
This commit is contained in:
Daniel Indictor 2020-07-25 05:07:24 -04:00 committed by GitHub
commit 1f629506a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -235,12 +235,17 @@ def expand_eav_filter(model_cls, key, value):
gr_name = config_cls.generic_relation_attr
datatype = Attribute.objects.get(slug=slug).datatype
value_key = ''
if datatype == Attribute.TYPE_ENUM and not isinstance(value, EnumValue):
lookup = '__value__{}'.format(fields[2]) if len(fields) > 2 else '__value'
value_key = 'value_{}{}'.format(datatype, lookup)
elif datatype == Attribute.TYPE_OBJECT:
value_key = 'generic_value_id'
else:
lookup = '__{}'.format(fields[2]) if len(fields) > 2 else ''
value_key = 'value_{}{}'.format(datatype, lookup)
kwargs = {
'value_{}{}'.format(datatype, lookup): value,
value_key: value,
'attribute__slug': slug
}
value = Value.objects.filter(**kwargs)