From 1a3df72038536c05b389df79fd499fcc97893f13 Mon Sep 17 00:00:00 2001 From: Linmao Song Date: Fri, 26 Jan 2018 15:16:28 +0000 Subject: [PATCH] Changes for Django2.0 --- dpaste/migrations/0001_initial.py | 2 +- dpaste/models.py | 4 ++-- dpaste/settings/base.py | 2 +- dpaste/views.py | 2 +- setup.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dpaste/migrations/0001_initial.py b/dpaste/migrations/0001_initial.py index 5bf120f..5640c22 100644 --- a/dpaste/migrations/0001_initial.py +++ b/dpaste/migrations/0001_initial.py @@ -25,7 +25,7 @@ class Migration(migrations.Migration): ('rght', models.PositiveIntegerField(editable=False, db_index=True)), ('tree_id', models.PositiveIntegerField(editable=False, db_index=True)), ('level', models.PositiveIntegerField(editable=False, db_index=True)), - ('parent', models.ForeignKey(related_name='children', blank=True, to='dpaste.Snippet', null=True)), + ('parent', models.ForeignKey(related_name='children', blank=True, to='dpaste.Snippet', null=True, on_delete=models.CASCADE)), ], options={ 'ordering': ('-published',), diff --git a/dpaste/models.py b/dpaste/models.py index 7cc2a37..9634372 100644 --- a/dpaste/models.py +++ b/dpaste/models.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals from random import SystemRandom from django.conf import settings -from django.core.urlresolvers import reverse +from django.urls import reverse from django.db import models from django.utils.functional import cached_property from django.utils.translation import ugettext_lazy as _ @@ -53,7 +53,7 @@ class Snippet(models.Model): choices=EXPIRE_CHOICES, default=EXPIRE_CHOICES[0][0]) expires = models.DateTimeField(_(u'Expires'), blank=True, null=True) view_count = models.PositiveIntegerField(_('View count'), default=0) - parent = models.ForeignKey('self', null=True, blank=True, related_name='children') + parent = models.ForeignKey('self', null=True, blank=True, related_name='children', on_delete=models.CASCADE) class Meta: ordering = ('-published',) diff --git a/dpaste/settings/base.py b/dpaste/settings/base.py index c608794..3bbcabf 100644 --- a/dpaste/settings/base.py +++ b/dpaste/settings/base.py @@ -88,7 +88,7 @@ LOGIN_REDIRECT_URL = '/' # Templates #============================================================================== -MIDDLEWARE_CLASSES = [ +MIDDLEWARE = [ 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', diff --git a/dpaste/views.py b/dpaste/views.py index b0873be..e6009b0 100644 --- a/dpaste/views.py +++ b/dpaste/views.py @@ -6,7 +6,7 @@ import json from django.conf import settings from django.core.exceptions import ObjectDoesNotExist -from django.core.urlresolvers import reverse +from django.urls import reverse from django.db.models import Count from django.http import (Http404, HttpResponse, HttpResponseBadRequest, HttpResponseRedirect) diff --git a/setup.py b/setup.py index 5103716..8a9f804 100644 --- a/setup.py +++ b/setup.py @@ -49,7 +49,7 @@ setup( }, include_package_data=True, install_requires=[ - 'django>=1.8,<2.0', + 'django>=1.8', 'pygments>=1.6', 'django-markup>=1.0', 'django-csp>=3.3',