from django.shortcuts import render from django.http import HttpResponse, HttpResponseRedirect from appli.forms import Formulaire from appli.models import Exercice from django.db.models import Q # Create your views here. def index(request): context = {} context['form'] = Formulaire() return render( request, 'appli/index.html', context) def form_data(request): # if this is a POST request we need to process the form data if request.method == 'POST': # create a form instance and populate it with data from the request: form = Formulaire(request.POST) # check whether it's valid: if 'entry_to_delete' in request.POST: # check whether there's a valid object and it's own by the right user. # then delete it. # if a GET (or any other method) we'll create a blank form else: form = Formulaire() return render(request, 'resultat.html', {'form': form})