Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/357.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在python vue js的views.py中处理GET和POST请求?_Javascript_Python_Django_Vue.js - Fatal编程技术网

Javascript 如何在python vue js的views.py中处理GET和POST请求?

Javascript 如何在python vue js的views.py中处理GET和POST请求?,javascript,python,django,vue.js,Javascript,Python,Django,Vue.js,我的观点是 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: name =

我的观点是

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:
     name = request.GET.get('name')
      na = {
    'name': name,

    }
     return render(request,"searchnew.html",na)
我有GET请求和其他POST请求。在这种情况下,我如何处理GET请求

这是我的请求

<a v-bind:href="'searchnew/?name='+post.name">{{post.name}}</a>

我得到的错误是 缩进错误:意外缩进


我如何才能传递此名称?

可能还有其他方法,如“PUT”,因此为“GET-inside-else”提供功能是不合适的。def searchnew(请求):if-request.method='POST':name=request.POST.GET('name')loc=request.POST.GET('location')d={'name':name,'loc':loc,}return render(请求,“searchnew.html”,d)else:name=request.GET.GET('name')na={'name':name,}return render(请求,“searchnew.html”,na)我尝试了此操作..但将错误获取为缩进错误:意外的缩进可能还有其他方法,如“PUT”,因此为GET inside else提供功能是不合适的。def searchnew(请求):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:name=request.GET.GET('name')na={'name':name,}return render(request,“searchnew.html”,na)我尝试了这个..但作为缩进获取错误错误:意外缩进
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)