foerderbarometer/input/views.py

31 lines
906 B
Python
Raw Normal View History

2020-09-21 12:27:16 +00:00
from django.shortcuts import render
2020-09-29 07:53:29 +00:00
from django.forms import modelformset_factory
from .models import Project
from .forms import ProjectForm
2020-09-29 09:08:16 +00:00
from django.http import HttpResponse
2020-09-22 10:21:05 +00:00
2020-09-30 12:26:08 +00:00
def intern(request):
2020-09-29 07:53:29 +00:00
# return HttpResponse("Hello, world. You're at the input form")
# ProjectFormSet = modelformset_factory(Project, fields='__all__')
2020-09-29 07:53:29 +00:00
if request.method == 'POST':
2020-09-29 09:47:29 +00:00
print('POST detected')
form = ProjectForm(request.POST, request.FILES)
if form.is_valid():
2020-09-29 09:47:29 +00:00
print('form valid')
form.save()
2020-09-29 09:47:29 +00:00
2020-09-29 07:53:29 +00:00
# do something.
2020-09-29 09:47:29 +00:00
else:
print("form not valid")
2020-09-29 07:53:29 +00:00
else:
2020-09-29 09:47:29 +00:00
print
form = ProjectForm()
return render(request, 'input/project.html', {'form': form})
2020-09-29 09:08:16 +00:00
def done(request):
return HttpResponse("Your data is save now.")
2020-09-30 12:26:08 +00:00
def extern(request):
return HttpResponse("The world out there is large and dangerous")