加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

django-URL之从URL中获取关键字(七)

发布时间:2020-12-15 17:07:02 所属栏目:大数据 来源:网络整理
导读:主要用于查询操作。 主要目录 book/views.py from django.http import HttpResponse from django.shortcuts render # Create your views here. def index(request): return render(request, " index.html " ) search(request): search =request.GET.get( que

主要用于查询操作。

主要目录

book/views.py

from django.http import HttpResponse
from django.shortcuts   render

# Create your views here.
def index(request):
    return render(request,"index.html")

 search(request):
    search=request.GET.get(query)
    return HttpResponse('<h1>{}</h1>'.format(search))

book/urls.py

from django.urls  path
from .  views

urlpatterns = [
    path('',views.index,name='index'),path(search/',views.search,1)">search
<!DOCTYPE html>
<html lang=en">
<head>
    <meta charset=UTF-8">
    <title>Title</title>
    <style>
        p{font-size: 28px;}
    </style>
</head>
<body>
<form action={%url '%}>
<input type=text" name=">
</form>
</body>
</html>

启动服务,会显示Index界面

输入关键字:以python为例

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读