views.py 832 B

12345678910111213141516171819202122232425262728
  1. from django.shortcuts import render
  2. from django.http import HttpResponse, HttpResponseNotFound, Http404
  3. # Create your views here.
  4. def index(request): # HttRequest
  5. return HttpResponse("Страница приложения women.")
  6. def categories(request, cat_id):
  7. return HttpResponse(f"<h1>Статьи по категориям</h1><p>id: {cat_id}</p>")
  8. def categories_by_slug(request, cat_slug):
  9. if request.GET:
  10. print(request.GET)
  11. return HttpResponse(f"<h1>Статьи по категориям</h1><p>slug: {cat_slug}</p>")
  12. def archive(request, year):
  13. if year > 2025:
  14. raise Http404()
  15. return HttpResponse(f"<h1>Архив по годам</h1><p>{year}</p>")
  16. def page_not_found(request, exception):
  17. return HttpResponseNotFound("<h1>Страница не найдена</h1>")