fix error with Location.get_child() in editor

This commit is contained in:
Laura Klünder 2017-12-24 13:23:19 +01:00
parent 5a034dc1fa
commit 38edfe4216
2 changed files with 3 additions and 3 deletions

View file

@ -336,7 +336,7 @@ class ChangeSet(models.Model):
objects.setdefault(obj.__class__, {})[pk] = obj
for pk, obj in objects.get(LocationRedirect, {}).items():
target = obj.target.get_child()
target = obj.target.get_child(obj.target)
objects.setdefault(LocationSlug, {})[target.pk] = target
objects.setdefault(target.__class__, {})[target.pk] = target

View file

@ -46,10 +46,10 @@ class LocationSlug(SerializableMixin, models.Model):
objects = LocationSlugManager()
def get_child(self):
def get_child(self, instance=None):
for model in get_submodels(Location)+[LocationRedirect]:
with suppress(AttributeError):
return getattr(self, model._meta.default_related_name)
return getattr(instance or self, model._meta.default_related_name)
return None
def get_slug(self):