unknown 3 månader sedan
förälder
incheckning
569457989b

+ 2 - 0
courses/django_kind/sitewomen/women/urls.py

@@ -7,6 +7,8 @@ register_converter(converters.FourDigitYearConverter, "year4")
 
 urlpatterns = [
     path('', views.index), # http://127.0.0.1:8000
+    # path('details/', views.post_detail),
+    path('posts/<int:year>', views.posts_list),
     path('cats/<int:cat_id>/', views.categories), # http://127.0.0.1:8000/cats/1/
     path('cats/<slug:cat_slug>/', views.categories_by_slug), # http://127.0.0.1:8000/cats/asdfad/
     # re_path(r"^archive/(?P<year>[0-9]{4})", views.archive),

+ 17 - 0
courses/django_kind/sitewomen/women/views.py

@@ -24,5 +24,22 @@ def archive(request, year):
     return HttpResponse(f"<h1>Архив по годам</h1><p>{year}</p>")
 
 
+def post_detail(request):
+    if request.GET:
+        ans = ""
+        for key, value in request.GET.items():
+            ans += f'{key}={value}|'
+        return HttpResponse(ans[:-1])
+    else:
+        return HttpResponse("GET is empty")
+
+
+def posts_list(request, year):
+    if 1990 <= year <= 2023:
+        return HttpResponse(f'posts: {year}')
+    else:
+        raise Http404()
+
+
 def page_not_found(request, exception):
     return HttpResponseNotFound("<h1>Страница не найдена</h1>")