Merge branch 'feature/content-pages' into 'develop'
Added 404 pages See merge request gm/gm-backend!236
This commit is contained in:
commit
2d2442e8bd
|
|
@ -1,5 +1,6 @@
|
||||||
"""News app views."""
|
"""News app views."""
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.http import Http404
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from django.utils import translation
|
from django.utils import translation
|
||||||
from rest_framework import generics, permissions, response
|
from rest_framework import generics, permissions, response
|
||||||
|
|
@ -40,8 +41,14 @@ class NewsMixinView:
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
def get_object(self):
|
def get_object(self):
|
||||||
return self.get_queryset() \
|
instance = self.get_queryset().filter(
|
||||||
.filter(slugs__values__contains=[self.kwargs['slug']]).first()
|
slugs__values__contains=[self.kwargs['slug']]
|
||||||
|
).first()
|
||||||
|
|
||||||
|
if instance is None:
|
||||||
|
raise Http404
|
||||||
|
|
||||||
|
return instance
|
||||||
|
|
||||||
|
|
||||||
class NewsListView(NewsMixinView, generics.ListAPIView):
|
class NewsListView(NewsMixinView, generics.ListAPIView):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user