summaryrefslogtreecommitdiff
path: root/app/jrnl/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/jrnl/models.py')
-rw-r--r--app/jrnl/models.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/app/jrnl/models.py b/app/jrnl/models.py
index d0b9120..b9018bf 100644
--- a/app/jrnl/models.py
+++ b/app/jrnl/models.py
@@ -5,6 +5,7 @@ import re
from django.contrib.gis.db import models
from django.utils.html import format_html
from django.urls import reverse
+from django.apps import apps
from django.template.loader import render_to_string
from django.conf import settings
from django.template import Context
@@ -156,7 +157,7 @@ class Entry(models.Model):
@property
def get_previous_admin_url(self):
n = self.get_previous_by_pub_date()
- return "/admin/jrnl/entry/%s/change/" % n.pk
+ return reverse('admin:%s_%s_change' %(self._meta.app_label, self._meta.model_name), args=[n.id] )
@property
@@ -165,8 +166,11 @@ class Entry(models.Model):
@property
def get_next_admin_url(self):
- n = self.get_next_by_pub_date()
- return "/admin/jrnl/entry/%s/change/" % n.pk
+ model = apps.get_model(app_label=self._meta.app_label, model_name=self._meta.model_name)
+ try:
+ return reverse('admin:%s_%s_change' %(self._meta.app_label, self._meta.model_name), args=[self.get_next_by_pub_date().pk] )
+ except model.DoesNotExist:
+ return ''
def save(self):
if self.pk: