Browse Source

update 404

master^2
Jakub Škrabánek 4 years ago
parent
commit
1b2b7e3aac
  1. 6
      .idea/vcs.xml
  2. 6
      accounts/views.py
  3. 4
      loginproject/settings.py
  4. 4
      loginproject/urls.py
  5. 18
      templates/404.html
  6. 7
      templates/home.html

6
.idea/vcs.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

6
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"

4
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

4
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")
]

18
templates/404.html

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>404</title>
</head>
<body>
<h1>ERROR 404</h1>
<h2>Stránka nenalezena</h2>
<br>
<a href="/">HOME</a>
<script>
setTimeout(function() {
window.location.href = "/";
},5000);
</script>
</body>
</html>

7
templates/home.html

@ -5,13 +5,18 @@
<title>Title</title>
</head>
<body>
<h1>Login system</h1>
<h1>Systém formuláře s přihlášením</h1>
{% if user.is_authenticated %}
<div>ahoj, {{ user.username }} </div>
<a href="{% url 'formular' %}">Formulář</a>
<a href="{% url 'seznam' %}">Seznam</a>
<br>
<a href="{% url 'logout' %}">Logout</a>
{% else %}
<p>Nejsi přihlášený</p>
<a href="{% url 'seznam'%}">Seznam</a>
<br>
<a href="{% url 'login' %}">Login</a>
<a href="{% url 'reg' %}">Registrace</a>
<a href="{% url 'password_reset' %}">RESET PW</a>

Loading…
Cancel
Save