Ignore:
Timestamp:
Mar 31, 2012, 5:59:05 PM (14 years ago)
Author:
Alex Dehnert <adehnert@…>
Branches:
master, space-access, stable, stage
Children:
4b1f99b
Parents:
3534e89
git-author:
Alex Dehnert <adehnert@…> (03/31/12 17:59:05)
git-committer:
Alex Dehnert <adehnert@…> (03/31/12 17:59:05)
Message:

Don't do any prefetching if we don't need to

select_related() selects *everything*, so we can't just blithely run
select_related(*list(prefetch_fields)) without checking prefetch_fields
is non-empty.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • asadb/groups/views.py

    r3534e89 rc409ae1  
    840840        # Prefetch foreign keys
    841841        prefetch_fields = groups.models.Group.reporting_prefetch()
    842         prefetch_fields.intersection_update(basic_fields)
    843         qs = qs.select_related(*list(prefetch_fields))
     842        prefetch_fields = prefetch_fields.intersection(basic_fields)
     843        if prefetch_fields:
     844            qs = qs.select_related(*list(prefetch_fields))
    844845        for group in qs:
    845846            group_data = [getattr(group, field) for field in basic_fields]
Note: See TracChangeset for help on using the changeset viewer.