Select related users when returning enrollments.

Modify CourseEnrollment.enrollments_for_user to select the related user
object. This saves us from a bunch of redundant queries on the student
dashboard.
This commit is contained in:
David Ormsbee
2017-02-20 09:38:44 -05:00
parent e6e32d7964
commit 351c34816c

View File

@@ -1439,7 +1439,7 @@ class CourseEnrollment(models.Model):
@classmethod
def enrollments_for_user(cls, user):
return cls.objects.filter(user=user, is_active=1)
return cls.objects.filter(user=user, is_active=1).select_related('user')
@classmethod
def enrollment_status_hash_cache_key(cls, user):