From c53bc77b8294312f1c571fd1f63a8623581a3027 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Tue, 27 Nov 2018 21:36:22 +0530 Subject: [PATCH] Adding opts to context for Django version 2 and above --- categories/editor/tree_editor.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/categories/editor/tree_editor.py b/categories/editor/tree_editor.py index 8310fcd..72c40c3 100644 --- a/categories/editor/tree_editor.py +++ b/categories/editor/tree_editor.py @@ -148,7 +148,7 @@ class TreeEditor(admin.ModelAdmin): self.list_display_links, self.list_filter, self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self.list_editable, self) - elif django.VERSION[0] == 2: + elif django.VERSION[0] >= 2: params = ( request, self.model, list_display, self.list_display_links, self.list_filter, self.date_hierarchy, @@ -250,6 +250,8 @@ class TreeEditor(admin.ModelAdmin): } if django.VERSION[0] == 1 and django.VERSION[1] < 4: context['root_path'] = self.admin_site.root_path + elif django.VERSION[0] >= 2: + context['opts'] = self..model._meta else: selection_note_all = ungettext('%(total_count)s selected', 'All %(total_count)s selected', cl.result_count)