Commit 928e4359 authored by Giorgos Korfiatis's avatar Giorgos Korfiatis

snf_django: Fix select_related in ListCommand

Pass all related fields in a single call, because select_related does not
chain as expected (yet). See https://code.djangoproject.com/ticket/16855

Also pass prefetch_related in a uniform way.
parent 373da652
......@@ -250,10 +250,10 @@ class ListCommand(SynnefoCommand):
objects = self.object_class.objects
try:
for sr in select_related:
objects = objects.select_related(sr)
for pr in prefetch_related:
objects = objects.prefetch_related(pr)
if select_related:
objects = objects.select_related(*select_related)
if prefetch_related:
objects = objects.prefetch_related(*prefetch_related)
objects = objects.filter(**self.filters)
objects = objects.exclude(**self.excludes)
except FieldError 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