You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
676 B

4 years ago
  1. from django.shortcuts import render
  2. from django.forms import modelformset_factory
  3. from .models import Project
  4. from django.http import HttpResponse
  5. def index(request):
  6. # return HttpResponse("Hello, world. You're at the input form")
  7. ProjectFormSet = modelformset_factory(Project, fields='__all__')
  8. if request.method == 'POST':
  9. formset = ProjectFormSet(request.POST, request.FILES)
  10. if formset.is_valid():
  11. formset.save()
  12. # do something.
  13. else:
  14. formset = ProjectFormSet()
  15. return render(request, 'input/project.html', {'formset': formset})
  16. def done(request):
  17. return HttpResponse("Your data is save now.")