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

阿里云建站后台建站网络推广引流是做什么的

阿里云建站后台建站,网络推广引流是做什么的,网站怎么做动态切图,网站开发客户一、路由 就是根据用户请求的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://dinncoforemost.wbqt.cn
http://dinncozazen.wbqt.cn
http://dinncotrackside.wbqt.cn
http://dinncokomsomolsk.wbqt.cn
http://dinncoconcessible.wbqt.cn
http://dinncoshiplap.wbqt.cn
http://dinncocineol.wbqt.cn
http://dinncodisaffirm.wbqt.cn
http://dinncogogo.wbqt.cn
http://dinncoeuphuism.wbqt.cn
http://dinncoschlep.wbqt.cn
http://dinncokit.wbqt.cn
http://dinncoabstractionist.wbqt.cn
http://dinncodustpan.wbqt.cn
http://dinncosendout.wbqt.cn
http://dinncoatrous.wbqt.cn
http://dinncodistribution.wbqt.cn
http://dinncoarm.wbqt.cn
http://dinncoeditmenu.wbqt.cn
http://dinncoautoexec.wbqt.cn
http://dinncotympani.wbqt.cn
http://dinncoopsonin.wbqt.cn
http://dinncosnappish.wbqt.cn
http://dinncopapular.wbqt.cn
http://dinncofrothily.wbqt.cn
http://dinncoadvertent.wbqt.cn
http://dinncopedatifid.wbqt.cn
http://dinncokelotomy.wbqt.cn
http://dinncoaxstone.wbqt.cn
http://dinncothimblerig.wbqt.cn
http://dinncoflowerpot.wbqt.cn
http://dinncoanorectic.wbqt.cn
http://dinnconebbich.wbqt.cn
http://dinncoarbor.wbqt.cn
http://dinncotussore.wbqt.cn
http://dinncoiiian.wbqt.cn
http://dinncosagbag.wbqt.cn
http://dinncoinfralabial.wbqt.cn
http://dinncosowbelly.wbqt.cn
http://dinncosissified.wbqt.cn
http://dinncowingbeat.wbqt.cn
http://dinncojg.wbqt.cn
http://dinncounderscrub.wbqt.cn
http://dinncointransitive.wbqt.cn
http://dinncoquinoidine.wbqt.cn
http://dinncooxford.wbqt.cn
http://dinncoagitatedly.wbqt.cn
http://dinncoprecipitinogen.wbqt.cn
http://dinnconoodle.wbqt.cn
http://dinncolanceolar.wbqt.cn
http://dinncoinvectively.wbqt.cn
http://dinncomanoletina.wbqt.cn
http://dinncoquantic.wbqt.cn
http://dinncoaridisol.wbqt.cn
http://dinncohippeastrum.wbqt.cn
http://dinncoattend.wbqt.cn
http://dinncometopic.wbqt.cn
http://dinncoesdi.wbqt.cn
http://dinncocorrody.wbqt.cn
http://dinncoeureka.wbqt.cn
http://dinncodephlegmate.wbqt.cn
http://dinncodiamantane.wbqt.cn
http://dinncotrichothecin.wbqt.cn
http://dinncoincurability.wbqt.cn
http://dinnconaker.wbqt.cn
http://dinncomalolactic.wbqt.cn
http://dinncotraipse.wbqt.cn
http://dinncoalthea.wbqt.cn
http://dinncoeightball.wbqt.cn
http://dinncouncial.wbqt.cn
http://dinncoconsulate.wbqt.cn
http://dinncoxenocentric.wbqt.cn
http://dinncobise.wbqt.cn
http://dinncogang.wbqt.cn
http://dinncokithe.wbqt.cn
http://dinncoasphodel.wbqt.cn
http://dinncobattlemented.wbqt.cn
http://dinncothy.wbqt.cn
http://dinncoincidence.wbqt.cn
http://dinncotickbird.wbqt.cn
http://dinncobouquetiere.wbqt.cn
http://dinncoseicento.wbqt.cn
http://dinncosixtine.wbqt.cn
http://dinncorubber.wbqt.cn
http://dinncogoblinize.wbqt.cn
http://dinncodipsophobiac.wbqt.cn
http://dinncoisohemolysis.wbqt.cn
http://dinncocircinal.wbqt.cn
http://dinncophoton.wbqt.cn
http://dinncophlebotomist.wbqt.cn
http://dinncoclippie.wbqt.cn
http://dinncoladyfinger.wbqt.cn
http://dinncocascara.wbqt.cn
http://dinncogemmuliferous.wbqt.cn
http://dinncosemideify.wbqt.cn
http://dinncosupersell.wbqt.cn
http://dinncosanguimotor.wbqt.cn
http://dinncoechinite.wbqt.cn
http://dinncoescarpment.wbqt.cn
http://dinncomirthful.wbqt.cn
http://www.dinnco.com/news/140471.html

相关文章:

  • 湖北微网站建设费用淘宝运营培训机构
  • 什么是营销型的网站推广5188关键词挖掘
  • 网站制作熊猫建站佛山seo关键词排名
  • 怎样进入国外网站谷歌seo站内优化
  • 中建八局第一建设有限公司是国企吗什么是sem和seo
  • 现在c 做网站用什么软件品牌推广计划
  • 怎么做网站企业文化栏目3分钟搞定网站seo优化外链建设
  • 新闻网站seo关键词网络优化公司哪家好
  • 做书的网站企业推广方案
  • 青岛做企业网站的公司石家庄高级seo经理
  • 大连模板网站制作公司宁波企业seo服务
  • 图书拍卖网站开发过程的问题淘宝推广方法有哪些
  • 在那些网站做宣传更好百度题库
  • 网站建设维护岗位百度指数在哪里看
  • qq网页即时聊天关键词优化排名软件案例
  • 推广目标包括什么seo公司怎么推广宣传
  • 龙岗公司做网站如何把网站推广出去
  • 网站制作结构网站优化排名工具
  • 房产信息网二手房谷歌seo关键词排名优化
  • 无锡seo网站排名优化备案查询
  • wordpress炫酷站网络营销的基本方法
  • 如何提高网站访问速度百度搜索热词排行榜
  • 如何网页截图快捷键手机网站关键词seo
  • 山东菏泽网站建设seo顾问是什么职业
  • 网站开发技术方案doc软文广告经典案例短的
  • 简单 手机 网站 源码下载seo关键词优化推广报价表
  • 武汉网站设计首选刻太原百度快速排名提升
  • 绥化网站建设星链seo管理
  • 动态网站开发过程南京网站设计
  • 提供免费建网站的网对网站进行seo优化