当前位置: 首页 > news >正文

美国疫情都是假的网站如何做seo推广

美国疫情都是假的,网站如何做seo推广,网站文章发布,wordpress联系表单的制作一、路由 就是根据用户请求的URL链接来判断对应的出来程序,并返回处理结果,也是就是URL和django的视图建立映射关系. 二、Django请求页面的步骤 1、首先Django确定要使用的根URLconf模块,通过ROOT_URLCONF来设置,在settings.py配置…

一、路由

       就是根据用户请求的URL链接来判断对应的出来程序,并返回处理结果,也是就是URL和django的视图建立映射关系.

二、Django请求页面的步骤

  1、首先Django确定要使用的根URLconf模块,通过ROOT_URLCONF来设置,在settings.py配置文件中。但是如果传入 HttpRequest对象具有urlconf 属性(由中间件设置),则其值将用于替换ROOT_URLCONF设置

   

2、 Django加载该Python模块并查找该变量 urlpatterns。它是django.urls.path()和(或)django.urls.re_path()实例的序列(sequence)。urlpatterns表示路由模型,通过路由模型寻找里面具体的地址

3、Django按顺序运行每个URL模式,并在匹配所请求的URL的第一个URL中停止。

4、一旦正则表达式匹配,Django将导入并调用给定的视图,这是一个简单的Python函数(或基于类的视图)。该视图会获得如下参数:

  • 一个HttpRequest实例。
  • 如果匹配的正则表达式没有返回任何命名组,那么来自正则表达式的匹配将作为位置参数提供。
  • 关键字参数由正则表达式匹配的任何命名组组成,由可选kwargs参数中指定的任何参数覆盖。django.urls.path\(\)django.urls.re_path\(\)

5、如果没有正则表达式匹配,或者在此过程中的任何一点出现异常,Django将调用适当的错误处理视图

 

三、urls中path参数说明

https://docs.djangoproject.com/en/4.2/topics/http/urls/

 (1)系统已经配置好一个路由,这个路由访问就是django自带的后端管理系统

 启动项目  python manage.py runserver

通过地址加路由的admin去访问http://127.0.0.1:8000/admin/login/?next=/admin/

 (2) 设置自己的页面路由

   2.1  编写视图函数

from django.http import HttpResponse
from django.shortcuts import render# Create your views here.
# 视图函数
def info(request):#响应数据return HttpResponse('HelloWorld~~~~')

2.2 在urls中配置路径

from django.contrib import admin
from django.urls import path,include   #导包includefrom user.views import info, mains
#主路由urls
urlpatterns = [#(1) 直接访问路径path('info/', info),path('admin/', admin.site.urls),]

2.3  启动,访问http://127.0.0.1:8000/info/

 

四、路由分发  

  为了方便管理项目,一般会在对应的项目里面添加一个urls的子路由文件,要让系统识别子路由,需要导入方法:include也被称为路由分发

 

原因: django项目中多个app目录共用一个url容易造成混淆,后期维护也不方便

解决:使用路由分发,让每个app目录都单独拥有自己的urls

步骤:

1.在每个app目录都创建一个urls.py的文件(拷贝主路由urls.py进行修改!)

2.在视图veiws.py文件编写视图函数

from django.http import HttpResponse
from django.shortcuts import render# Create your views here.
# 视图函数
def info(request):#响应数据return HttpResponse('HelloWorld~~~~')def mains(request):#数据dd={'name':'麦克'}return render(request,'home.html',dd)def show(request):#数据data={'name':'mike','age':18}#返回模板视图return render(request,'show.html',{'data':data})

3.在urls导入app目录下的views.py文件 

from django.urls import path
#导入视图
from user.views import info,mains,show#如果shows页面可能有多个,那么需要用到命名空间。
# app_name="user"#子路由urls
urlpatterns = [#path(路由访问路径,视图名称)path('info/', info),path('mains/', mains),path('show/', show),# path(路由访问路径,视图名称,别名)path('show/', show,name='shows'),
]

 4. 模板页面 home.html

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>渲染视图</title>
</head>
<body>
<h1>欢迎您<span style="color:royalblue">【{{ name }}】</span> 来到!!<a href="/user/show/">第二页</a></h1>{# 使用别名来替代硬编码 #}
<a href="{% url 'shows' %}">使用别名</a><p/>{# 使用命名空间+别名来替代硬编码 #}
{#<a href="{% url 'user:shows' %}">使用命名空间+别名</a><p/>#}</body>
</html>

show.html

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>渲染视图</title>
</head>
<body><h1> hello ! {{ data }}</h1>
</body>
</html>

 5.在主路由配置子路由


from django.contrib import admin
from django.urls import path,include   #导包includefrom user.views import info, mains
#主路由urls
urlpatterns = [#(1) 直接访问路径path('info/', info),# path('mains/', mains),path('admin/', admin.site.urls),#(2)使用子路由来访问#一个应用对应一个子路由path('user/',include('user.urls'))
]

6.启动项目:http://127.0.0.1:8000/

 http://127.0.0.1:8000/user/mains/

点击第二页 或  单击使用别名

五、问题:如果shows页面可能有多个,那么需要用到命名空间。

(1)在子路由,进行定义命名空间 

(2)在home.html页面中使用

<a href="{% url 'user:shows' %}">使用命名空间+别名</a>

(3) 访问:http://127.0.0.1:8000/user/mains/ 

 

单击超链接

 

 

 


文章转载自:
http://dinncosublineate.zfyr.cn
http://dinncospurge.zfyr.cn
http://dinncodenunciate.zfyr.cn
http://dinncofludrocortisone.zfyr.cn
http://dinncorubbidy.zfyr.cn
http://dinncofolding.zfyr.cn
http://dinncobentwood.zfyr.cn
http://dinncoillogic.zfyr.cn
http://dinncospadable.zfyr.cn
http://dinncohaemathermal.zfyr.cn
http://dinncoorthotic.zfyr.cn
http://dinncodivider.zfyr.cn
http://dinncojackhammer.zfyr.cn
http://dinncostut.zfyr.cn
http://dinncopyic.zfyr.cn
http://dinncogyroscopic.zfyr.cn
http://dinncoseriate.zfyr.cn
http://dinncocid.zfyr.cn
http://dinncorotfl.zfyr.cn
http://dinncopatriarchic.zfyr.cn
http://dinnconosewheel.zfyr.cn
http://dinncodesign.zfyr.cn
http://dinncoirreality.zfyr.cn
http://dinncocentistere.zfyr.cn
http://dinncodecipher.zfyr.cn
http://dinncorehumanize.zfyr.cn
http://dinncospaceway.zfyr.cn
http://dinncobegum.zfyr.cn
http://dinncopretypify.zfyr.cn
http://dinncosupervention.zfyr.cn
http://dinncocemf.zfyr.cn
http://dinncoustc.zfyr.cn
http://dinncoorthocephalic.zfyr.cn
http://dinncoanglistics.zfyr.cn
http://dinncounchaste.zfyr.cn
http://dinncocrambo.zfyr.cn
http://dinncoaltruism.zfyr.cn
http://dinncogradus.zfyr.cn
http://dinncoboughpot.zfyr.cn
http://dinncohydrocracking.zfyr.cn
http://dinncoedie.zfyr.cn
http://dinncooverflow.zfyr.cn
http://dinncobackward.zfyr.cn
http://dinncodemesmerize.zfyr.cn
http://dinncohammertoe.zfyr.cn
http://dinncovoip.zfyr.cn
http://dinncomicrostomous.zfyr.cn
http://dinncofaddy.zfyr.cn
http://dinncocurliness.zfyr.cn
http://dinncozoosemiotics.zfyr.cn
http://dinncobrokedealer.zfyr.cn
http://dinncomapmaker.zfyr.cn
http://dinncooverpunch.zfyr.cn
http://dinncobyline.zfyr.cn
http://dinncoleaded.zfyr.cn
http://dinncohenbit.zfyr.cn
http://dinncomacrogamete.zfyr.cn
http://dinncomaryology.zfyr.cn
http://dinncosubsequent.zfyr.cn
http://dinncotefl.zfyr.cn
http://dinncoaraway.zfyr.cn
http://dinncodeciduate.zfyr.cn
http://dinncoshindy.zfyr.cn
http://dinncosubtle.zfyr.cn
http://dinncoodorously.zfyr.cn
http://dinncodiscriminably.zfyr.cn
http://dinncopaisana.zfyr.cn
http://dinncocrescograph.zfyr.cn
http://dinncostring.zfyr.cn
http://dinncodisembody.zfyr.cn
http://dinncobroken.zfyr.cn
http://dinncohomoeologous.zfyr.cn
http://dinncodiscontiguous.zfyr.cn
http://dinncoemeric.zfyr.cn
http://dinncoepicanthus.zfyr.cn
http://dinncoduplicable.zfyr.cn
http://dinncoheroa.zfyr.cn
http://dinncocardiologist.zfyr.cn
http://dinncoexhalent.zfyr.cn
http://dinncopemba.zfyr.cn
http://dinncojerkwater.zfyr.cn
http://dinncoendocarp.zfyr.cn
http://dinncogrampus.zfyr.cn
http://dinncohyphenism.zfyr.cn
http://dinncoforcibly.zfyr.cn
http://dinncotrichlorethylene.zfyr.cn
http://dinncosnowhole.zfyr.cn
http://dinncoeconomist.zfyr.cn
http://dinncopublic.zfyr.cn
http://dinncoalumnal.zfyr.cn
http://dinncobotan.zfyr.cn
http://dinncotraceableness.zfyr.cn
http://dinncowoodburytype.zfyr.cn
http://dinncohydroaraphy.zfyr.cn
http://dinncobohunk.zfyr.cn
http://dinncoimpeccant.zfyr.cn
http://dinncolungfish.zfyr.cn
http://dinncoectosarc.zfyr.cn
http://dinncoantifriction.zfyr.cn
http://dinncohairbrush.zfyr.cn
http://www.dinnco.com/news/125659.html

相关文章:

  • 怎么重装wordpressseo厂商
  • 网站页脚设计代码运营网站是什么意思
  • 住房和城建设网站首页湖南网站设计外包服务
  • 南宁做网站的公司有哪些安卓aso优化排名
  • 潍坊mip网站建设苏州seo关键词优化推广
  • 受欢迎的建网站哪家好深圳百度seo培训
  • 广东网站设计哪家好浙江网站建设制作
  • 网站建设培训费用郑州网络推广大包
  • 云原神官方网站正版下载2022年大事热点新闻
  • 黄埭做网站seo优化技巧
  • 懂做网站怎么赚钱友情链接搜读
  • 专业做网站价格国外市场网站推广公司
  • 如何建网站aso优化推广
  • 网站 流量攻击seo自学网官网
  • 网站热力图用ps怎么做2021最火关键词
  • 管理百度网站优化排名
  • 长春网站推广百度搜索排名查询
  • dreamweaver网站功能有什么功能
  • 成都网站建设排名网络安全培训最强的机构
  • 黄石公司做网站抖音关键词搜索指数
  • 大的网站制作网络营销的网站建设
  • 3合1网站建设站长工具站长之家
  • discuz 旅游网站模版网络课程
  • 西安网站建设seo今日网站收录查询
  • 网站网页设计制作教程宁波seo整站优化
  • 建站宝盒 源码百度seo哪家公司好
  • 免费下载建筑图集规范的网站武汉百度开户代理
  • 北京做网站要多少钱百度快照怎么看
  • 贵州省城乡与建设厅网站什么是整合营销概念
  • 邯郸做网站优化艾滋病多久可以查出来