mirror of
https://github.com/jazzband/django-categories.git
synced 2026-03-16 22:30:24 +00:00
Merge pull request #147 from gagandeep/master
Fix for Django 2.1 breaking Admin tree editor
This commit is contained in:
commit
3765851320
3 changed files with 20 additions and 9 deletions
|
|
@ -148,13 +148,20 @@ 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)
|
||||
else:
|
||||
elif django.VERSION[0] == 1 or (django.VERSION[0] == 2 and django.VERSION[1] < 1):
|
||||
params = (
|
||||
request, self.model, list_display,
|
||||
self.list_display_links, self.list_filter, self.date_hierarchy,
|
||||
self.search_fields, self.list_select_related,
|
||||
self.list_per_page, self.list_max_show_all,
|
||||
self.list_editable, self)
|
||||
else:
|
||||
params = (
|
||||
request, self.model, list_display,
|
||||
self.list_display_links, self.list_filter, self.date_hierarchy,
|
||||
self.search_fields, self.list_select_related,
|
||||
self.list_per_page, self.list_max_show_all,
|
||||
self.list_editable, self, self.sortable_by)
|
||||
cl = TreeChangeList(*params)
|
||||
except IncorrectLookupParameters:
|
||||
# Wacky lookup parameters were given, so redirect to the main
|
||||
|
|
@ -243,7 +250,7 @@ class TreeEditor(admin.ModelAdmin):
|
|||
}
|
||||
if django.VERSION[0] == 1 and django.VERSION[1] < 4:
|
||||
context['root_path'] = self.admin_site.root_path
|
||||
else:
|
||||
elif django.VERSION[0] == 1 or (django.VERSION[0] == 2 and django.VERSION[1] < 1):
|
||||
selection_note_all = ungettext('%(total_count)s selected', 'All %(total_count)s selected', cl.result_count)
|
||||
|
||||
context.update({
|
||||
|
|
@ -251,6 +258,9 @@ class TreeEditor(admin.ModelAdmin):
|
|||
'selection_note': _('0 of %(cnt)s selected') % {'cnt': len(cl.result_list)},
|
||||
'selection_note_all': selection_note_all % {'total_count': cl.result_count},
|
||||
})
|
||||
else:
|
||||
context['opts'] = self.model._meta
|
||||
|
||||
context.update(extra_context or {})
|
||||
return render_to_response(self.change_list_template or [
|
||||
'admin/%s/%s/change_list.html' % (app_label, opts.object_name.lower()),
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class CategoryFKField(ForeignKey):
|
|||
|
||||
try:
|
||||
from south.modelsinspector import add_introspection_rules
|
||||
add_introspection_rules([], ["^categories\.fields\.CategoryFKField"])
|
||||
add_introspection_rules([], ["^categories\.fields\.CategoryM2MField"])
|
||||
add_introspection_rules([], [r"^categories\.fields\.CategoryFKField"])
|
||||
add_introspection_rules([], [r"^categories\.fields\.CategoryM2MField"])
|
||||
except ImportError:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -21,12 +21,13 @@ class SimpleText(models.Model):
|
|||
def __unicode__(self):
|
||||
return self.name
|
||||
|
||||
# If using the get_absolute_url method, put the following line at the top of this file:
|
||||
from django.db.models import permalink
|
||||
|
||||
@permalink
|
||||
def get_absolute_url(self):
|
||||
return ('simpletext_detail_view_name', [str(self.id)])
|
||||
try:
|
||||
from django.db.models import permalink
|
||||
return permalink('simpletext_detail_view_name', [str(self.id)])
|
||||
except ImportError:
|
||||
from django.urls import reverse
|
||||
return reverse('simpletext_detail_view_name', args=[str(self.id)])
|
||||
|
||||
|
||||
class SimpleCategory(CategoryBase):
|
||||
|
|
|
|||
Loading…
Reference in a new issue