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
|
2020-09-29 09:29:15 +00:00
|
|
|
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")
|
2020-09-29 09:29:15 +00:00
|
|
|
# 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')
|
2020-09-29 09:29:15 +00:00
|
|
|
form = ProjectForm(request.POST, request.FILES)
|
|
|
|
if form.is_valid():
|
2020-09-29 09:47:29 +00:00
|
|
|
print('form valid')
|
2020-09-29 09:29:15 +00:00
|
|
|
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
|
2020-09-29 09:29:15 +00:00
|
|
|
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.")
|