mercredi 1 avril 2020

how to pass my_dict to redirect, like redirect('home',my_dict)

I want to pass this error into the template, but it is not working,

def addcomment(request):
name = request.POST['name']
comment = request.POST['comment']
if name=="" and comment=="":
    my_dict = {'error':'blank fields not allowed'}

    return redirect('home',my_dict)

Comment(name = request.POST['name'],comment = request.POST['comment']).save()
return HttpResponseRedirect('/')



Aucun commentaire:

Enregistrer un commentaire