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):
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'),
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()
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__()
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:
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:
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():
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)
ALLOWED_HOSTS = [
"www.sommitrealweird.co.uk",
"www.sommitrealweird.co.uk.",
+ "10.0.3.191",
]
MANAGERS = ADMINS
}
}
-MIDDLEWARE_CLASSES = (
+MIDDLEWARE = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
+ 'django.contrib.messages',
'bpcms',
'generic',
'blog',