change home view

This commit is contained in:
prance 2022-01-27 23:23:22 +01:00
parent 341339ca8b
commit f02e4cd8a3
6 changed files with 16 additions and 10 deletions

View File

View File

@ -1,6 +1,4 @@
from django.contrib.auth.models import User
from django.db import models
from django.contrib.auth.base_user import AbstractBaseUser
from django.contrib.auth.models import AbstractUser

View File

@ -37,7 +37,7 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'crispy_forms',
'MUOR'
'MUOR',
]
MIDDLEWARE = [

View File

@ -25,7 +25,9 @@ urlpatterns = [
path('admin/', admin.site.urls),
path('', include('django.contrib.auth.urls')),
path('signup/', SignUpView.as_view(), name='signup'),
path('', TemplateView.as_view(template_name='home.html'), name='home'),
path('favicon.ico', RedirectView.as_view(url=staticfiles_storage.url('images/favicon.ico'))),
path('test/', views.test, name='test')
path('welcome/', TemplateView.as_view(template_name='home.html'),
name='home'),
path('favicon.ico', RedirectView.as_view(
url=staticfiles_storage.url('images/favicon.ico'))),
path('', views.home, name='home')
]

View File

@ -1,13 +1,16 @@
from django.contrib.auth import logout
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django.http import JsonResponse
from django.shortcuts import redirect
from django.urls import reverse_lazy
from django.views import generic
from .models import Profile
class SignUpForm(UserCreationForm):
class Meta:
model = User
model = Profile
fields = ('username', 'email',)
def save(self, commit=True):
@ -20,5 +23,8 @@ class SignUpView(generic.CreateView):
template_name = 'registration/signup.html'
def test(request):
return JsonResponse(request.COOKIES)
def home(request):
if request.user.is_authenticated:
logout(request)
return redirect("/welcome")

Binary file not shown.