初试Django-简单地修改urls里面的内容改一改

注意httprespone只是加字符串,当然可以直接内嵌html代码,但是不能打开一个文件

 

想要直接导入一个文件,可以这样子,在template目录下面直接创建一个html文件,然后在urls中导入一个新的包叫render如下

from django.shortcuts import  HttpResponse,render

再输入如下代码

def login(request):
    print('nihaoya')
    # return HttpResponse('<h1>login</h1>')
    return render(request,'login.html')
    pass

即可

相关文章:

  • 2021-05-16
  • 2022-12-23
  • 2022-02-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-30
  • 2021-07-31
  • 2022-12-23
相关资源
相似解决方案