Browse Source

Fix siblings for custom admin site

Denis K 8 years ago
parent
commit
d6e16a03b0
2 changed files with 8 additions and 5 deletions
  1. 4 2
      jet/templatetags/jet_tags.py
  2. 4 3
      jet/utils.py

+ 4 - 2
jet/templatetags/jet_tags.py

@@ -219,7 +219,8 @@ def jet_sibling_object_url(context, next):
     model = type(original)
     preserved_filters_plain = context.get('preserved_filters', '')
     preserved_filters = dict(parse_qsl(preserved_filters_plain))
-    queryset = get_model_queryset(model, preserved_filters=preserved_filters)
+    admin_site = get_admin_site(context)
+    queryset = get_model_queryset(admin_site, model, preserved_filters=preserved_filters)
 
     sibling_object = None
     object_pks = list(queryset.values_list('pk', flat=True))
@@ -235,7 +236,8 @@ def jet_sibling_object_url(context, next):
     if sibling_object is None:
         return
 
-    url = reverse('admin:%s_%s_change' % (
+    url = reverse('%s:%s_%s_change' % (
+        admin_site.name,
         model._meta.app_label,
         model._meta.model_name
     ), args=(sibling_object.pk,))

+ 4 - 3
jet/utils.py

@@ -164,10 +164,11 @@ class SuccessMessageMixin(object):
         return self.success_message % cleaned_data
 
 
-def get_model_queryset(model, preserved_filters=None):
-    model_admin = admin.site._registry.get(model)
+def get_model_queryset(admin_site, model, preserved_filters=None):
+    model_admin = admin_site._registry.get(model)
 
-    changelist_url = urlresolvers.reverse('admin:%s_%s_changelist' % (
+    changelist_url = urlresolvers.reverse('%s:%s_%s_changelist' % (
+        admin_site.name,
         model._meta.app_label,
         model._meta.model_name
     ))