From 654dddce81f3957a4c6116740d80c3b9d261d425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Dlouh=C3=BD?= Date: Sat, 1 Feb 2020 09:18:19 +0100 Subject: [PATCH 1/3] fixes to Django 3.0 --- categories/base.py | 13 +++++++++++-- categories/editor/tree_editor.py | 7 ++++--- categories/templatetags/category_tags.py | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/categories/base.py b/categories/base.py index eb1ccd3..29319f4 100644 --- a/categories/base.py +++ b/categories/base.py @@ -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): """ diff --git a/categories/editor/tree_editor.py b/categories/editor/tree_editor.py index 5b8c6fe..f832df5 100644 --- a/categories/editor/tree_editor.py +++ b/categories/editor/tree_editor.py @@ -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' diff --git a/categories/templatetags/category_tags.py b/categories/templatetags/category_tags.py index cdc4593..69d2aad 100644 --- a/categories/templatetags/category_tags.py +++ b/categories/templatetags/category_tags.py @@ -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 From a88a5f78254fef4dfeedca90406208cefeb450c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Dlouh=C3=BD?= Date: Sun, 2 Feb 2020 08:17:35 +0100 Subject: [PATCH 2/3] add newer Django versions to tox.ini --- tox.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index ad33bcb..73c9f99 100644 --- a/tox.ini +++ b/tox.ini @@ -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 From d7dd98593a5fec437a64e54395d95b97eb8f45fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Dlouh=C3=BD?= Date: Sun, 2 Feb 2020 09:21:19 +0100 Subject: [PATCH 3/3] update django-mptt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 731db0d..c8f4509 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -django-mptt>=0.9.0,<0.10 +django-mptt>=0.9.0,<0.11 unicode-slugify==0.1.3