Hi, 

when I try to add an exclude filter to an annotated field with a 
FilteredRelation I get a FieldError on the annotated field. 

For exemple if I modify django 
test filtered_relation.tests.FilteredRelationTests.test_with_join from  

def test_with_join(self):
self.assertSequenceEqual(
Author.objects.annotate(
book_alice=FilteredRelation('book', condition=Q(book__title__iexact='poem 
by alice')),
).filter(book_alice__isnull=False),
[self.author1]
)

to 

def test_with_join_exclude(self):
self.assertSequenceEqual(
Author.objects.annotate(
book_alice=FilteredRelation('book', condition=Q(book__title__iexact='poem 
by alice')),
).exclude(book_alice__isnull=False),
[]
)

I get the following error : django.core.exceptions.FieldError: Cannot 
resolve keyword 'book_alice' into field. Choices are: book, content_object, 
content_type, content_type_id, favorite_books, id, name, object_id

I think the issue comme from the function split_exclude(self, filter_expr, 
can_reuse, names_with_path)  because it create a new Query without the 
_filtered_relations datas.

How can I manage to do this ?


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/68bec592-53b9-4ff3-ac37-6ca3be50b84c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to