unknown преди 3 месеца
родител
ревизия
9e6413d76d

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+__pycache__/

+ 2 - 2
courses/django_kind/sitewomen/sitewomen/settings.py

@@ -23,9 +23,9 @@ BASE_DIR = Path(__file__).resolve().parent.parent
 SECRET_KEY = 'django-insecure-tac__m@^ndq4-9svbw*h_al*^$cwe1u2q+tmcyax-49rebdvfs'
 SECRET_KEY = 'django-insecure-tac__m@^ndq4-9svbw*h_al*^$cwe1u2q+tmcyax-49rebdvfs'
 
 
 # SECURITY WARNING: don't run with debug turned on in production!
 # SECURITY WARNING: don't run with debug turned on in production!
-DEBUG = True
+DEBUG = False
 
 
-ALLOWED_HOSTS = []
+ALLOWED_HOSTS = ['127.0.0.1', 'localhost']
 
 
 
 
 # Application definition
 # Application definition

+ 4 - 0
courses/django_kind/sitewomen/sitewomen/urls.py

@@ -17,8 +17,12 @@ Including another URLconf
 from django.contrib import admin
 from django.contrib import admin
 from django.urls import path, include
 from django.urls import path, include
 from women import views
 from women import views
+from women.views import page_not_found
 
 
 urlpatterns = [
 urlpatterns = [
     path('admin/', admin.site.urls),
     path('admin/', admin.site.urls),
     path('', include('women.urls')),
     path('', include('women.urls')),
 ]
 ]
+
+
+handler404 = page_not_found

+ 10 - 2
courses/django_kind/sitewomen/women/views.py

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