check category_id, not category to avoid additional queries

This commit is contained in:
Laura Klünder 2017-10-27 13:47:23 +02:00
parent 25b478f227
commit feb62bec39

View file

@ -233,7 +233,7 @@ class LocationGroup(Location, models.Model):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.orig_priority = self.priority self.orig_priority = self.priority
self.orig_category = self.category self.orig_category_id = self.category_id
self.orig_color = self.color self.orig_color = self.color
def _serialize(self, **kwargs): def _serialize(self, **kwargs):
@ -266,7 +266,9 @@ class LocationGroup(Location, models.Model):
obj.register_change(force=True) obj.register_change(force=True)
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
if self.orig_color != self.color or self.priority != self.orig_priority or self.category != self.orig_category: if (self.orig_color != self.color or
self.priority != self.orig_priority or
self.category_id != self.orig_category_id):
self.register_changed_geometries() self.register_changed_geometries()
super().save(*args, **kwargs) super().save(*args, **kwargs)