From 1b2b7e3aac8c92ed8aa5863abcf0d91c10a435da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=A0krab=C3=A1nek?= Date: Fri, 22 Apr 2022 09:41:20 +0200 Subject: [PATCH] update 404 --- .idea/vcs.xml | 6 ++++++ accounts/views.py | 6 ++++++ loginproject/settings.py | 4 ++-- loginproject/urls.py | 4 +++- templates/404.html | 18 ++++++++++++++++++ templates/home.html | 7 ++++++- 6 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 .idea/vcs.xml create mode 100644 templates/404.html diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/accounts/views.py b/accounts/views.py index 515131d..c21126f 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -7,3 +7,9 @@ class regView(generic.CreateView): form_class = UserCreationForm success_url = reverse_lazy("login") template_name = "registration/reg.html" + + +def pageNotFoundView(request, exception): + render(request, "404.html", status=404) + +handler404 = "accounts.views.pageNotFoundView" \ No newline at end of file diff --git a/loginproject/settings.py b/loginproject/settings.py index 37cec8e..74da230 100644 --- a/loginproject/settings.py +++ b/loginproject/settings.py @@ -23,9 +23,9 @@ BASE_DIR = Path(__file__).resolve().parent.parent SECRET_KEY = 'django-insecure-(__uc&%9#ymprsk0(9c9ykmkvc+%%wvm3*$bvz!oo+2a-3cb6r' # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = False -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = ["localhost", "127.0.0.1"] # Application definition diff --git a/loginproject/urls.py b/loginproject/urls.py index 1908dd1..645638e 100644 --- a/loginproject/urls.py +++ b/loginproject/urls.py @@ -21,5 +21,7 @@ urlpatterns = [ path('admin/', admin.site.urls), path("ucet/", include("accounts.urls")), path("ucet/", include("django.contrib.auth.urls")), - path("",TemplateView.as_view(template_name="home.html"), name="home") + path("",TemplateView.as_view(template_name="home.html"), name="home"), + path("",TemplateView.as_view(template_name="home.html"), name="formular"), + path("",TemplateView.as_view(template_name="home.html"), name="seznam") ] diff --git a/templates/404.html b/templates/404.html new file mode 100644 index 0000000..d93ebfe --- /dev/null +++ b/templates/404.html @@ -0,0 +1,18 @@ + + + + + 404 + + +

ERROR 404

+

Stránka nenalezena

+
+HOME + + + \ No newline at end of file diff --git a/templates/home.html b/templates/home.html index 9c8476d..3939039 100644 --- a/templates/home.html +++ b/templates/home.html @@ -5,13 +5,18 @@ Title -

Login system

+

Systém formuláře s přihlášením

{% if user.is_authenticated %}
ahoj, {{ user.username }}
+Formulář +Seznam +
Logout {% else %}

Nejsi přihlášený

+Seznam +
Login Registrace RESET PW