From a0e3e037c1c56789e21831acaaeaafea147191cb Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Thu, 3 May 2018 18:18:13 -0700 Subject: [PATCH] Bail out of join_group early if already immediate parent. I'd rather make the extra select than a delete and reinsert. --- etiquette/objects.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/etiquette/objects.py b/etiquette/objects.py index 0f9d127..03f0763 100644 --- a/etiquette/objects.py +++ b/etiquette/objects.py @@ -198,6 +198,9 @@ class GroupableMixin: if self == group: raise ValueError('Cant join self') + if self.get_parent() == group: + return + self.leave_group(commit=False) group.add_child(self, commit=commit)