Commits

Luke Plant  committed 82ca062

Fixed O(n) performance problem on contacts admin

  • Participants
  • Parent commits 823082c

Comments (0)

Files changed (1)

File contacts/models.py

         ordering = ['name']
 
 
+class ContactManager(models.Manager):
+    use_for_related_fields = True
+
+    def get_query_set(self):
+        return super(ContactManager, self).get_query_set().select_related('home_group')
+
+
 class Contact(models.Model):
     name = models.CharField(max_length=100)
     address = models.TextField(blank=True)
     church_member = models.BooleanField()
     include_on_email_lists = models.BooleanField(default=True)
 
+    objects = ContactManager()
+
     def __unicode__(self):
         return self.name