From: Brett Parker Date: Fri, 6 Aug 2021 08:09:29 +0000 (+0000) Subject: Changes for django 2.2 X-Git-Url: https://git.sommitrealweird.co.uk/sommitrealweird.git/commitdiff_plain/HEAD?hp=075239c730821f8acd231cd25987bb1c16031421 Changes for django 2.2 --- diff --git a/sommitrealweird/blog/views.py b/sommitrealweird/blog/views.py index 52fab00..1f29f98 100644 --- a/sommitrealweird/blog/views.py +++ b/sommitrealweird/blog/views.py @@ -36,6 +36,7 @@ def blog_index(request, section=None): except: raise Http404 else: + return render(request, 'blog/blog_index.html') raise Http404 def blog_view(request, year=None, month=None, day=None, hour=None, minutes=None, section=None, slug=None): diff --git a/sommitrealweird/bpcms/models.py b/sommitrealweird/bpcms/models.py index 5df5a43..5c49f49 100644 --- a/sommitrealweird/bpcms/models.py +++ b/sommitrealweird/bpcms/models.py @@ -2,7 +2,7 @@ from django.db import models from django.conf import settings from django.contrib import admin from django.core.cache import cache -from django.core.urlresolvers import reverse +from django.urls import reverse FORMAT_CHOICES = ( ('rst', 'reStructuredText'), @@ -24,7 +24,7 @@ class Document(models.Model): title = models.CharField(max_length=150) islive = models.BooleanField(default=False) extracss = models.ManyToManyField(CSSDocument, blank=True) - folder = models.ForeignKey('Folder', null=True, blank=True) + folder = models.ForeignKey('Folder', on_delete=models.SET_NULL, null=True, blank=True) format = models.CharField(max_length=10, choices=FORMAT_CHOICES) slug = models.SlugField() content = models.TextField() @@ -78,7 +78,7 @@ class Document(models.Model): class Folder(models.Model): title = models.CharField(max_length=150) slug = models.SlugField() - parent = models.ForeignKey('self', null=True, blank=True) + parent = models.ForeignKey('self', on_delete=models.SET_NULL, null=True, blank=True) def __str__(self): return self.__unicode__() diff --git a/sommitrealweird/bpcms/views.py b/sommitrealweird/bpcms/views.py index 3651743..e0087c8 100644 --- a/sommitrealweird/bpcms/views.py +++ b/sommitrealweird/bpcms/views.py @@ -2,6 +2,7 @@ from bpcms.models import CSSDocument, Document, Folder from django.http import Http404, HttpResponse from django.shortcuts import render from django.template import RequestContext, loader +import sys def document_view(request, slug=None, folders=None): if folders == None and slug == None: @@ -28,7 +29,7 @@ def document_view(request, slug=None, folders=None): if folder != None: try: - if not request.user.is_authenticated(): + if not request.user.is_authenticated: doc = Document.objects.get(slug__exact=slug, islive__exact=True, folder__exact=folder) else: @@ -44,11 +45,12 @@ def document_view(request, slug=None, folders=None): raise Http404 else: try: - if not request.user.is_authenticated(): + if not request.user.is_authenticated: doc = Document.objects.get(slug__exact=slug, islive__exact=True, folder__isnull=True) else: doc = Document.objects.get(slug__exact=slug, folder__isnull=True) except: + sys.stderr.write("Unexpected error:", sys.exc_info()[0]) try: folder = Folder.objects.get(slug__exact=slug, parent__isnull=True) if not request.user.is_authenticated(): diff --git a/sommitrealweird/photo/models.py b/sommitrealweird/photo/models.py index 3a5d123..31751c3 100644 --- a/sommitrealweird/photo/models.py +++ b/sommitrealweird/photo/models.py @@ -26,7 +26,7 @@ class Photo(models.Model): image = models.ImageField(upload_to=get_upload_path, null=True) caption = models.TextField(blank=True, null=True) order = models.IntegerField(blank=True, null=True) - album = models.ForeignKey('Album') + album = models.ForeignKey('Album', on_delete=models.CASCADE) def __unicode__(self): return "%s" %(self.image) diff --git a/sommitrealweird/settings.py b/sommitrealweird/settings.py index 67b8f32..6eb539f 100644 --- a/sommitrealweird/settings.py +++ b/sommitrealweird/settings.py @@ -14,6 +14,7 @@ ADMINS = ( ALLOWED_HOSTS = [ "www.sommitrealweird.co.uk", "www.sommitrealweird.co.uk.", + "10.0.3.191", ] MANAGERS = ADMINS @@ -55,7 +56,7 @@ CACHES = { } } -MIDDLEWARE_CLASSES = ( +MIDDLEWARE = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', @@ -96,6 +97,7 @@ INSTALLED_APPS = ( 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', + 'django.contrib.messages', 'bpcms', 'generic', 'blog',