Merge pull request #150 from PetrDlouhy/django30

Add support for Django 3.0
This commit is contained in:
Brent O'Connor 2020-02-03 07:52:08 -06:00 committed by GitHub
commit 31206db328
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 8 deletions

View file

@ -2,12 +2,12 @@
This is the base class on which to build a hierarchical category-like model
with customizable metadata and its own name space.
"""
import sys
from django.contrib import admin
from django.db import models
from django import forms
from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import force_text
from mptt.models import MPTTModel
from mptt.fields import TreeForeignKey
@ -17,6 +17,15 @@ from slugify import slugify
from .editor.tree_editor import TreeEditor
from .settings import ALLOW_SLUG_CHANGE, SLUG_TRANSLITERATOR
from django.utils.translation import ugettext_lazy as _
if sys.version_info[0] < 3: # Remove this after dropping support of Python 2
from django.utils.encoding import python_2_unicode_compatible
else:
def python_2_unicode_compatible(x):
return x
class CategoryManager(models.Manager):
"""

View file

@ -4,7 +4,7 @@ from django.contrib.admin.views.main import ChangeList
from django.http import HttpResponseRedirect
from django.utils.translation import ugettext_lazy as _
from django.contrib.admin.options import IncorrectLookupParameters
from django.shortcuts import render_to_response
from django.shortcuts import render
import django
@ -170,7 +170,8 @@ class TreeEditor(admin.ModelAdmin):
# the 'invalid=1' parameter was already in the query string, something
# is screwed up with the database, so display an error page.
if ERROR_FLAG in list(request.GET.keys()):
return render_to_response(
return render(
request,
'admin/invalid_setup.html', {'title': _('Database error')})
return HttpResponseRedirect(request.path + '?' + ERROR_FLAG + '=1')
@ -262,7 +263,7 @@ class TreeEditor(admin.ModelAdmin):
context['opts'] = self.model._meta
context.update(extra_context or {})
return render_to_response(self.change_list_template or [
return render(request, self.change_list_template or [
'admin/%s/%s/change_list.html' % (app_label, opts.object_name.lower()),
'admin/%s/change_list.html' % app_label,
'admin/change_list.html'

View file

@ -2,7 +2,7 @@ from django import template
from django.apps import apps
from django.template import (Node, TemplateSyntaxError, VariableDoesNotExist)
from django.template.base import FilterExpression
from django.utils.six import string_types
from six import string_types
from categories.base import CategoryBase
from categories.models import Category
from mptt.utils import drilldown_tree_for_node

View file

@ -1,2 +1,2 @@
django-mptt>=0.9.0,<0.10
django-mptt>=0.9.0,<0.11
unicode-slugify==0.1.3

View file

@ -3,7 +3,7 @@ envlist =
begin
py27-lint
py27-django{111}
py36-django{111,2,21,22}
py36-django{111,2,21,22,3}
coverage-report
[testenv]
@ -11,6 +11,7 @@ deps=
django2: Django>=2.0,<2.1
django21: Django>=2.1,<2.2
django22: Django>=2.2,<2.3
django3: Django>=3.0,<3.1
django111: Django>=1.11,<1.12
coverage
pillow