我对使用 pip 和 python 相当陌生。我在 python 中安装了其他库,但无法安装 pandas。安装 22% 后出现很多错误。查看图像中的错误
有人可以帮忙吗?
我只是在玩 Django 登录和注销阶段。我有一个登录页面,如果用户使用“GET”获取它,他就会获取表单,如果他提交表单,它就会提交给相同的view.login函数。问题是当我尝试使用\' if request.method==\'POST\'. 我收到一个错误\'User has not attribute method\',我不明白,为什么\'User\'传递的是对象而不是request对象?\n这里是views.py的代码:
from django.shortcuts import render\nfrom django.http import HttpResponse, Http404, HttpResponseRedirect\nfrom .models import Flight,Passenger\nfrom django.urls import reverse\nfrom django.contrib.auth import authenticate,login, logout\nfrom django.contrib.auth.models import User\n\n\ndef index(request):\n if not request.user.is_authenticated:\n return render(request,"login.html")\n\n context={\n "flights":Flight.objects.all()\n }\n return render(request,"index.html",context)\n\ndef flight(request,flight_id):\n flight= Flight.objects.get(pk=flight_id)\n passengers = flight.passengers.all()\n non_passengers = Passenger.objects.exclude(flight=flight).all()\n context={\n "flight":flight,\n "passengers":passengers,\n "non_passengers":non_passengers\n }\n return render(request,"flight.html",context)\n\ndef book(request,flight_id):\n passenger_id = int(request.POST["passenger"])\n flight = Flight.objects.get(pk=flight_id)\n passenger = Passenger.objects.get(pk=passenger_id)\n …Run Code Online (Sandbox Code Playgroud)