loginform

This commit is contained in:
Mikhail Ronchyk 2021-04-10 20:46:08 +03:00
parent 195f7bff1f
commit a3c0e6c382
13 changed files with 61 additions and 9 deletions

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HighNeed</title>
</head>
<body>
<h1>Hello</h1>
{% block title %}Home{% endblock %}
{% block content %}
{% if user.is_authenticated %}
Hi {{ user.username }}!
<p><a href="{% url 'logout' %}">Log Out</a></p>
{% else %}
<p>You are not logged in</p>
<a href="{% url 'login' %}">Log In</a>
{% endif %}
{% endblock %}
</body>
</html>

View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Login</title>
</head>
<body>
<h2>Log In</h2>
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Log In</button>
</form>
</body>
</html>

View File

@ -1,7 +1,10 @@
from django.urls import path
from django.views.generic import TemplateView
from . import views
app_name = 'events'
urlpatterns = [
path('', views.index, name='index'),
path('', views.index, name='events'),
#path('events/', TemplateView.as_view(template_name='events/index.html'), name='events'),
]

View File

@ -1,8 +1,8 @@
from django.shortcuts import render
# Create your views here.
from django.http import HttpResponse
from django.http import HttpResponse, HttpResponseRedirect
def index(request):
return HttpResponse("Hello, world. You're at the HighNeed.pl.")
return HttpResponseRedirect("index.html")

View File

@ -9,7 +9,7 @@ https://docs.djangoproject.com/en/3.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""
import os
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
@ -37,6 +37,7 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'events',
]
MIDDLEWARE = [
@ -54,7 +55,7 @@ ROOT_URLCONF = 'highneed.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
@ -75,8 +76,12 @@ WSGI_APPLICATION = 'highneed.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'highneed',
'USER': 'admin',
'PASSWORD': '1234',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}
@ -105,7 +110,7 @@ AUTH_PASSWORD_VALIDATORS = [
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
TIME_ZONE = 'Europe/Warsaw'
USE_I18N = True
@ -118,3 +123,5 @@ USE_TZ = True
# https://docs.djangoproject.com/en/3.1/howto/static-files/
STATIC_URL = '/static/'
LOGIN_REDIRECT_URL = 'events'
LOGOUT_REDIRECT_URL = 'events'

View File

@ -15,8 +15,11 @@ Including another URLconf
"""
from django.contrib import admin
from django.urls import path, include
from django.views.generic import TemplateView
urlpatterns = [
path('events/', include('events.urls')),
#path('events/', include('events.urls')),
path('events/', TemplateView.as_view(template_name='events/index.html'), name='events'),
path('admin/', admin.site.urls),
path('accounts/', include('django.contrib.auth.urls')),
]