|
@@ -1,5 +1,5 @@
|
|
|
from django.shortcuts import render
|
|
|
-from django.http import HttpResponse
|
|
|
+from django.http import HttpResponse, HttpResponseNotFound, Http404
|
|
|
|
|
|
|
|
|
# Create your views here.
|
|
@@ -13,8 +13,16 @@ def categories(request, cat_id):
|
|
|
|
|
|
|
|
|
def categories_by_slug(request, cat_slug):
|
|
|
+ if request.GET:
|
|
|
+ print(request.GET)
|
|
|
return HttpResponse(f"<h1>Статьи по категориям</h1><p>slug: {cat_slug}</p>")
|
|
|
|
|
|
|
|
|
def archive(request, year):
|
|
|
- return HttpResponse(f"<h1>Архив по годам</h1><p>{year}</p>")
|
|
|
+ if year > 2025:
|
|
|
+ raise Http404()
|
|
|
+ return HttpResponse(f"<h1>Архив по годам</h1><p>{year}</p>")
|
|
|
+
|
|
|
+
|
|
|
+def page_not_found(request, exception):
|
|
|
+ return HttpResponseNotFound("<h1>Страница не найдена</h1>")
|