From 730a7dfe5abd21bdedc85a6c600789aa22174740 Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Wed, 6 May 2020 23:13:52 +0200 Subject: [PATCH] =?UTF-8?q?P=C5=99id=C3=A1n=20TreeNode.get=5Fadmin=5Furl()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/models.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/seminar/models.py b/seminar/models.py index 43d6e59d..927afba7 100644 --- a/seminar/models.py +++ b/seminar/models.py @@ -14,6 +14,7 @@ from django.utils.text import slugify from django.urls import reverse from django.core.cache import cache from django.core.exceptions import ObjectDoesNotExist +from django.contrib.contenttypes.models import ContentType from django.utils.text import get_valid_filename from imagekit.models import ImageSpecField, ProcessedImageField from imagekit.processors import ResizeToFit, Transpose @@ -1303,6 +1304,10 @@ class TreeNode(PolymorphicModel): def aktualizuj_nazev(self): raise NotImplementedError("Pokus o aktualizaci názvu obecného TreeNode místo konkrétní instance") + def get_admin_url(self): + content_type = ContentType.objects.get_for_model(self.__class__) + return reverse("admin:%s_%s_change" % (content_type.app_label, content_type.model), args=(self.id,)) + class RocnikNode(TreeNode): class Meta: db_table = 'seminar_nodes_rocnik'