From: Brett Parker Date: Sun, 24 May 2015 10:19:19 +0000 (+0100) Subject: Clean up photos so that it does 404s X-Git-Url: https://git.sommitrealweird.co.uk/sommitrealweird.git/commitdiff_plain/f69c55b527dcbf1c578baa95afbac75211249fc2?ds=inline;hp=5f6086698809e16bfe5c6c5316d1ed687cf56dc9 Clean up photos so that it does 404s --- diff --git a/sommitrealweird/photo/views.py b/sommitrealweird/photo/views.py index 28955ab..8501a6f 100644 --- a/sommitrealweird/photo/views.py +++ b/sommitrealweird/photo/views.py @@ -7,24 +7,29 @@ class AlbumListView(ListView): queryset = Album.objects.order_by('-name') paginate_by = 20 - def get_context_data(self, **kwargs): - context = super(AlbumListView, self).get_context_data(**kwargs) - return context - class PhotoListView(ListView): model = Photo paginate_by = 20 order_by = 'order, image' def get_queryset(self): - album = Album.objects.get(slug__exact=self.kwargs['slug']) - return Photo.objects.filter(album=album) + try: + album = Album.objects.get(slug__exact=self.kwargs['slug']) + return Photo.objects.filter(album=album) + except: + raise Http404 class PhotoView(DetailView): - model = Photo + + def get_queryset(self, **kwargs): + return Photo.objects.get(id=self.kwargs['id']).get_queryset() def get_object(self, **kwargs): - return Photo.objects.get(id=self.kwargs['id']) + try: + photo = Photo.objects.get(id=self.kwargs['id']) + return photo + except: + raise Http404 def get_context_data(self, **kwargs): context = super(PhotoView, self).get_context_data(**kwargs) @@ -52,4 +57,3 @@ class PhotoView(DetailView): context['prev_photo'] = prev_photo return context - diff --git a/sommitrealweird/settings.py b/sommitrealweird/settings.py index 497cad1..723ff4d 100644 --- a/sommitrealweird/settings.py +++ b/sommitrealweird/settings.py @@ -11,6 +11,11 @@ ADMINS = ( ('Brett Parker', 'iDunno@sommitrealweird.co.uk'), ) +ALLOWED_HOSTS = [ + "www.sommitrealweird.co.uk", + "www.sommitrealweird.co.uk.", +] + MANAGERS = ADMINS DATABASES = {