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.

18 lines
634 B

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