Problem with get and q objects

37 views
Skip to first unread message

ben

unread,
Jan 16, 2011, 9:56:17 AM1/16/11
to eav-django
Thanks for all your hard work. This is truly an awesome addition to
django.

I was playing around with your samples and I noticed that filtering
with .get or Q objects doesn't work. I get the exception. "Cannot
resolve keyword 'colour_exact' into field choices are: attrs, id,
price, title." I tested this and this problem manifests itself on both
1.2.3 and 1.3 beta 1. Is this feature not added yet or is it a bug? If
its not implemented where should I look to get started adding it. I
would have expected BaseEntity.__getattr__ to have handled all lookups
for every variety of filtering.

Thanks,
Ben

ben

unread,
Jan 16, 2011, 11:27:56 AM1/16/11
to eav-django
FYI. The previous post uses color_exact as the keyword. I know this is
wrong! I miss typed it. The error message should read:

"Cannot resolve keyword 'colour' into field choices are: attrs, id,
price, title."

Didn't want you thinking I didn't know how to use field lookups
properly.

Thanks,
Ben

Tom

unread,
Jan 20, 2011, 2:56:33 PM1/20/11
to eav-django
I am also interested in this.

zzart

unread,
Sep 25, 2012, 6:33:55 AM9/25/12
to eav-d...@googlegroups.com
For people who are still interested in Q objects using this eav. 
My workaround this problem is :

#First of generate list of Q objects for non eav fields
q_list = [Q(x) for x in predicates] 
kwargs = {'eav_field1__icontains': 'test', 'eav_field2': 'test2'}
# then depending what you want use OR or AND to join the two separate querysets 
qs = (Entity.objects.filter(reduce(operator.or_, q_list)) or Entity.objects.filter(**kwargs)).distinct()       

anyone have a better idea ? pliz share
Reply all
Reply to author
Forward
0 new messages