Django中,运行出现错误 "OSError: [Errno 22] Invalid argument: "F:\\DjangoProgram\\CampusCounselingSyste
m\\user\\templates\\<WSGIRequest: GET '\\user\\login'>"
解决方案:
views.py
from django.shortcuts import render_to_response
from django.http import HttpResponse
# Create your views here.
def index(request):
print("ok entered!")
return HttpResponse("You Entered!")
# return render_to_response(request,"index.html")
def login(request):
print("You enter the method of login")
return render_to_response(request,"login.html")
将render_to_response函数改成render函数
from django.shortcuts import render_to_response
from django.shortcuts import render
# Create your views here.
def index(request):
print("ok entered!")
# return HttpResponse("You Entered!")
return render(request,"index.html")
def login(request):
print("You enter the method of login")
return render(request,"login.html")
在PyCharm中也能看到,渲染视图HTML的时候会出现图标,问题成功解决。