[Vuejs]-How can I able to handle both GET and POST requests in views.py in python vue js?

2👍

def searchnew(request):
    if request.method == 'POST':
        name = request.POST.get('name')
        loc = request.POST.get('location')
        d = {
            'name': name,
            'loc': loc,

        }
        return render(request, "searchnew.html", d)
    else:
    # do the thing you want to do in GET method
        name = request.GET.get('name')
        na = {
           'name': name,
        }
        return render(request,"searchnew.html",na)

Leave a comment