basic form workflow added

This commit is contained in:
Benni Bärmann 2021-01-05 14:10:28 +01:00
parent 229f35f816
commit da8b58279f
4 changed files with 20 additions and 5 deletions

View File

@ -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/

View File

@ -1,3 +1,6 @@
from django.contrib import admin
from .models import Employee
# Register your models here.
admin.site.register([
Employee,
])

View File

@ -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')
]

View File

@ -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)