1
0
Fork 0
foerderbarometer/input/views.py

28 lines
813 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
def index(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.")