Commit 83322ab3 authored by Giorgos Korfiatis's avatar Giorgos Korfiatis

snf_django: Properly chain `exclude' queries

Although chained filters, e.g. filter(p1).filter(p2), can be summed up as
filter(p1, p2), this is not the case with exclude. If you want to exclude
those selected by p1 as well as those selected by p2, you need
exclude(p1).exclude(p2).
parent 655525a2
...@@ -255,7 +255,8 @@ class ListCommand(SynnefoCommand): ...@@ -255,7 +255,8 @@ class ListCommand(SynnefoCommand):
if prefetch_related: if prefetch_related:
objects = objects.prefetch_related(*prefetch_related) objects = objects.prefetch_related(*prefetch_related)
objects = objects.filter(**self.filters) objects = objects.filter(**self.filters)
objects = objects.exclude(**self.excludes) for key, value in self.excludes.iteritems():
objects = objects.exclude(**{key:value})
except FieldError as e: except FieldError as e:
raise CommandError(e) raise CommandError(e)
except Exception as e: except Exception as e:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment