From da8b58279f133dcbfe837d4e23df4e00dc5cee01 Mon Sep 17 00:00:00 2001 From: Benni Baermann Date: Tue, 5 Jan 2021 14:10:28 +0100 Subject: [PATCH] basic form workflow added --- eva/settings.py | 2 ++ evapp/admin.py | 5 ++++- evapp/urls.py | 3 ++- evapp/views.py | 15 ++++++++++++--- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/eva/settings.py b/eva/settings.py index ec840e3..b507344 100644 --- a/eva/settings.py +++ b/eva/settings.py @@ -15,6 +15,8 @@ from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent +# mails in development go to stdout +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ diff --git a/evapp/admin.py b/evapp/admin.py index 8c38f3f..067bbae 100644 --- a/evapp/admin.py +++ b/evapp/admin.py @@ -1,3 +1,6 @@ from django.contrib import admin +from .models import Employee -# Register your models here. +admin.site.register([ + Employee, + ]) diff --git a/evapp/urls.py b/evapp/urls.py index 6978be9..021ef20 100644 --- a/evapp/urls.py +++ b/evapp/urls.py @@ -1,7 +1,8 @@ from django.urls import path -from .views import EvaFormView +from .views import EvaFormView, success urlpatterns = [ path('', EvaFormView.as_view(), name='evaform'), + path('success', success, name='success') ] diff --git a/evapp/views.py b/evapp/views.py index 08e7d56..1a7e2e4 100644 --- a/evapp/views.py +++ b/evapp/views.py @@ -1,11 +1,20 @@ -from django.shortcuts import render from django.views.generic.edit import CreateView +from django.urls import reverse +from django.http import HttpResponse from .models import Employee from .forms import EmployeeForm -# Create your views here. +def success(request): + return HttpResponse("gut gemacht!") + class EvaFormView(CreateView): model = Employee - # fields = '__all__' # ['firstname'] form_class = EmployeeForm + + def get_success_url(self): + return reverse('success') + + def form_valid(self, form): + print("VALIDE!!!") + return super().form_valid(form)