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

wordpress连不上mysql8企业商务网站优化

wordpress连不上mysql8,企业商务网站优化,wordpress制作图片站,晋江外贸网站建设Django笔记 提示#xff1a;这里可以添加系列文章的所有文章的目录#xff0c;目录需要自己手动添加 例如#xff1a;第一章 Python 机器学习入门之pandas的使用 提示#xff1a;写完文章后#xff0c;目录可以自动生成#xff0c;如何生成可参考右边的帮助文档 文章目录…Django笔记 提示这里可以添加系列文章的所有文章的目录目录需要自己手动添加 例如第一章 Python 机器学习入门之pandas的使用 提示写完文章后目录可以自动生成如何生成可参考右边的帮助文档 文章目录 Django笔记创建django项目二、urls.py二、templates三、templates中几个基础操作四、templates中extend和include 创建django项目 提示这里可以添加本文要记录的大概内容 首先创建一个项目。 其次注意点为这里是虚拟环境所以一定要检测setting 中django包有无导入 启动环境在该文件夹下输入 python manage.py runserversetting.py 是相关配置文件 urls.py 是路径文件 在pycharm创建具体的app python manage.py startapp book二、urls.py 该py为设置浏览器路径文件 注意要补充from django.shortcuts import HttpResponse 简单操作但是开发不会这么做 from django.shortcuts import HttpResponse def index(request):return HttpResponse(hello)urlpatterns [path(admin/, admin.site.urls),path(index/,index) ]运行后在网页尾缀后面输入/index 2. 正常操作 在views.py中输入内容在urls.py中导入该views.py所在的包调用里面运行函数。 例如在book文件中的views.py中通过查询字符串query string:https://www.baidu.com/wdpythonab2 注意要加入from django.shortcuts import render,HttpResponse from django.shortcuts import render,HttpResponse # 在URL中携带参数 #1. 通过查询字符串query string:https://www.baidu.com/wdpythonab2 #2.在path中携带http://127.0.0.1:8000/book/2 # Create your views here. # 1 http://127.0.0.1:8000/book?id1 def book_detail_query_string(request):# request.GET{id:3}book_idrequest.GET.get(id)name_idrequest.GET.get(name)return HttpResponse(f查询的图书id是{book_id}图书名称是{name_id}) 在urls.py 中导入所在views.py的包如from book import views然后写入路径和所需参数的返回函数 from book import views urlpatterns [path(admin/, admin.site.urls),path(index/,index),path(book/,views.book_detail_query_string) ]最终形成的样式为 #2 # http://127.0.0.1:8000/book/2/水浒传 urlpatterns [path(admin/, admin.site.urls),# http://127.0.0.1:8000/indexpath(index/,index),# http://127.0.0.1:8000/book?id1namepath(book/,views.book_detail_query_string),# http://127.0.0.1:8000/book/1#在book_id前指定参数类型有两点好处:#1、以后在浏览器中如果bobk_id输入的是一个非整形、那么会出现404错误:/book/abc#2、在视图函数中得到的book_id就是一个整形否则就是str类型path(book/int:book_id/str:name_id/,views.book_detail_path), ]3.分模块化 新建一个app movie 在movie中的view加入所需函数 from django.shortcuts import render,HttpResponse# Create your views here. def movie_list(request):return HttpResponse(电影列表)def movie_detail(request,movie_id):return HttpResponse(f查询的电影id是{movie_id})随后在movie中的urls内加入路径 from django.urls import path from . import views #指定应用名称 app_namemovie urlpatterns [path(list/,views.movie_list,namemovie_list),path(detail/int:movie_id,views.movie_detail,namemovie_detail), ]最后在总的urls.py 中加入分段地址 from django.urls import path,include urlpatterns [# 分段地址path(movie/,include(movie.urls)) ] 整体运行结果为 二、templates 其实主要就三步 1.在所在app下的view.py中创建html路径 # Create your views here. def index(request):return render(request,index.html)2.在所在app下创建templates文件夹修改整体的setting.py加入一个所在app名字最后再在改templates文件夹中创建html 3.在该app名下的urls.py中创建连接views.py的路径导入view所在的函数和需要的地址。最后再在整体urls.py中做个读取入口 三、templates中几个基础操作 1.app下的模板 view界面 # Create your views here. def baidu(request):return render(request,baidu.html)html界面 !DOCTYPE html html langen headmeta charsetUTF-8title这是home下面的html/title /head bodyh1 stylebackground-color: pink这是home下面的html/h1 /body /html2.参数传递模板 view界面 def info(request):usernameAAAAbook{name:水浒传,author:施耐庵}books[{name:水浒传1, author: 施耐庵1},{name: 水浒传2, author: 施耐庵2},{name: 水浒传3, author: 施耐庵3}]class Person:def __init__(self, realname):self.realnamerealnamecontext{username: username,book: book,books:books,person:Person(BBB),}return render(request,info.html,contextcontext)html界面 !DOCTYPE html html langen headmeta charsetUTF-8title信息传递/title /head body p{{ username }}/p p图书名称{{ book.name }}/p p第一本书图书名称: {{ books.0.name }}/p p姓名为:{{ person.realname }}/p {% for book in books %}p{{ book.name }}/p {% endfor %}/body /html3.if参数模板 view界面 def if_view(request):age20context {age:age,}return render(request,if.html,contextcontext)html界面 !DOCTYPE html html langen headmeta charsetUTF-8titleif标签/title /head body {% if age 18 %}p已经满18/p {% elif age 18%}p不满18/p {% else %}p刚满18/p {% endif %} /body /html4.for参数模板 view界面 def for_view(request):books [{name: 水浒传1, author: 施耐庵1},{name: 水浒传2, author: 施耐庵2},{name: 水浒传3, author: 施耐庵3}]Person {name: 施耐庵,age: 18,height:180}context {books:books,Person:Person,}return render(request,for.html,contextcontext) html界面 !DOCTYPE html html langen headmeta charsetUTF-8titlefor标签/title /head body table theadtrtd序号/tdtd名称/tdtd作者/td/tr /theadtbody{% for book in books reversed%}trtd{{ forloop.counter }}/tdtd{{ book.name }}/tdtd{{ book.author }}/td/tr{% empty %}tr没有任何东西/tr{% endfor %}/tbody /tablediv{% for key,value in Person.items %}p{{ key }}:{{ value }}/p {% endfor %} /div/body /html4.with参数模板 view界面 def with_view(request):books [{name: 水浒传1, author: 施耐庵1},{name: 水浒传2, author: 施耐庵2},{name: 水浒传3, author: 施耐庵3}]context {books:books}return render(request,with.html,contextcontext)html界面 !DOCTYPE html html langen headmeta charsetUTF-8titlewith标签/title /head body {% with book1books.1 %}P{{ book1.name }}:{{ book1.author }}/P {% endwith %} /body /html5.url参数模板 view界面 def url_view(request):return render(request,url.html)def book_detail(request,book_id):return HttpResponse(f查询的图书id是{book_id})html界面 !DOCTYPE html html langen headmeta charsetUTF-8titleurl标签/title /head body a href{% url home:home_baidu%}百度/a a href{% url home:url_book_detail book_id1 %}图书详情/a /body /html总体的url from django.urls import path from . import views #指定应用名称 app_namehome urlpatterns [path(,views.index,namehome_index),path(baidu/,views.baidu,namehome_baidu),path(info/,views.info,namehome_info),path(if/,views.if_view,namehome_if),path(for/,views.for_view,namehome_for),path(with/,views.with_view,namehome_with),path(url/,views.url_view,nameurl_with),path(book/book_id,views.book_detail,nameurl_book_detail), ]四、templates中extend和include 子模板继承父模板用extend 父模板包含子模板用include 首先创建公用的父模版 其中{block}{endblock}为插槽 rmwz_base作为付模板 !DOCTYPE html html langen headmeta charsetUTF-8title{% block title %}{% endblock %}---hzc/title{% block head %}{% endblock %} /head body headerullia href/ 首页 /a/lilia href/course 创业课堂 /a/li/ul /header {% block body %}我是来自副模板的 {% endblock %} footer版权信息XXXX /footer /body /htmlrmwz_index作为子模板 {% extends rmwz_base.html %} {% block title %}首页 {% endblock %} {% block head %}stylebody{background-color: pink;}/style {% endblock %} {% block body %}{{ block.super }}{% include hotarticle.html %}div自己加入东西/div {% endblock %}hotarticle.html作为rmwz_index的子模板 div h2热门文章/h2ul{% for article in articles%}li{{ article }}/li{% endfor %}/ul /div其中view.py定义articles变量 def template_form(request):articles [小米su7,ChatGPT 5 发布 ]context {articles:articles}return render(request, rmwz_index.html,contextcontext)urls.py 载入地址链接 path(template/form/,views.template_form,nametemplate_form),实现效果
文章转载自:
http://www.morning.tstkr.cn.gov.cn.tstkr.cn
http://www.morning.ldzss.cn.gov.cn.ldzss.cn
http://www.morning.nqnqz.cn.gov.cn.nqnqz.cn
http://www.morning.kkwgg.cn.gov.cn.kkwgg.cn
http://www.morning.znknj.cn.gov.cn.znknj.cn
http://www.morning.wbxtx.cn.gov.cn.wbxtx.cn
http://www.morning.mnclk.cn.gov.cn.mnclk.cn
http://www.morning.xnnpy.cn.gov.cn.xnnpy.cn
http://www.morning.xqjh.cn.gov.cn.xqjh.cn
http://www.morning.tmxtr.cn.gov.cn.tmxtr.cn
http://www.morning.wschl.cn.gov.cn.wschl.cn
http://www.morning.hblkq.cn.gov.cn.hblkq.cn
http://www.morning.cpqwb.cn.gov.cn.cpqwb.cn
http://www.morning.dpdr.cn.gov.cn.dpdr.cn
http://www.morning.gsjzs.cn.gov.cn.gsjzs.cn
http://www.morning.tpnxr.cn.gov.cn.tpnxr.cn
http://www.morning.lrybz.cn.gov.cn.lrybz.cn
http://www.morning.bnzjx.cn.gov.cn.bnzjx.cn
http://www.morning.cbczs.cn.gov.cn.cbczs.cn
http://www.morning.fwlch.cn.gov.cn.fwlch.cn
http://www.morning.knryp.cn.gov.cn.knryp.cn
http://www.morning.mrpqg.cn.gov.cn.mrpqg.cn
http://www.morning.rfqkx.cn.gov.cn.rfqkx.cn
http://www.morning.fpkpz.cn.gov.cn.fpkpz.cn
http://www.morning.mnwsy.cn.gov.cn.mnwsy.cn
http://www.morning.zhengdaotang.cn.gov.cn.zhengdaotang.cn
http://www.morning.cjrmf.cn.gov.cn.cjrmf.cn
http://www.morning.qfdmh.cn.gov.cn.qfdmh.cn
http://www.morning.fwkjp.cn.gov.cn.fwkjp.cn
http://www.morning.clybn.cn.gov.cn.clybn.cn
http://www.morning.ndzhl.cn.gov.cn.ndzhl.cn
http://www.morning.ldzss.cn.gov.cn.ldzss.cn
http://www.morning.tkfnp.cn.gov.cn.tkfnp.cn
http://www.morning.gqfbh.cn.gov.cn.gqfbh.cn
http://www.morning.qcbhb.cn.gov.cn.qcbhb.cn
http://www.morning.ljbm.cn.gov.cn.ljbm.cn
http://www.morning.mttck.cn.gov.cn.mttck.cn
http://www.morning.psxwc.cn.gov.cn.psxwc.cn
http://www.morning.lnyds.cn.gov.cn.lnyds.cn
http://www.morning.kkgbs.cn.gov.cn.kkgbs.cn
http://www.morning.jxhlx.cn.gov.cn.jxhlx.cn
http://www.morning.hbpjb.cn.gov.cn.hbpjb.cn
http://www.morning.jpzcq.cn.gov.cn.jpzcq.cn
http://www.morning.zbmcz.cn.gov.cn.zbmcz.cn
http://www.morning.cgtfl.cn.gov.cn.cgtfl.cn
http://www.morning.ctlzf.cn.gov.cn.ctlzf.cn
http://www.morning.hmxb.cn.gov.cn.hmxb.cn
http://www.morning.kgsws.cn.gov.cn.kgsws.cn
http://www.morning.sftrt.cn.gov.cn.sftrt.cn
http://www.morning.fkgct.cn.gov.cn.fkgct.cn
http://www.morning.dpmkn.cn.gov.cn.dpmkn.cn
http://www.morning.srrrz.cn.gov.cn.srrrz.cn
http://www.morning.wngpq.cn.gov.cn.wngpq.cn
http://www.morning.sxygc.cn.gov.cn.sxygc.cn
http://www.morning.jgcxh.cn.gov.cn.jgcxh.cn
http://www.morning.snbry.cn.gov.cn.snbry.cn
http://www.morning.jxscp.cn.gov.cn.jxscp.cn
http://www.morning.cfqyx.cn.gov.cn.cfqyx.cn
http://www.morning.spdyl.cn.gov.cn.spdyl.cn
http://www.morning.dnconr.cn.gov.cn.dnconr.cn
http://www.morning.lssfd.cn.gov.cn.lssfd.cn
http://www.morning.rlksq.cn.gov.cn.rlksq.cn
http://www.morning.bwjgb.cn.gov.cn.bwjgb.cn
http://www.morning.pntzg.cn.gov.cn.pntzg.cn
http://www.morning.kwdfn.cn.gov.cn.kwdfn.cn
http://www.morning.rydbs.cn.gov.cn.rydbs.cn
http://www.morning.qmsbr.cn.gov.cn.qmsbr.cn
http://www.morning.bpmfg.cn.gov.cn.bpmfg.cn
http://www.morning.rbhqz.cn.gov.cn.rbhqz.cn
http://www.morning.msxhb.cn.gov.cn.msxhb.cn
http://www.morning.kxmyj.cn.gov.cn.kxmyj.cn
http://www.morning.pwmpn.cn.gov.cn.pwmpn.cn
http://www.morning.gbcnz.cn.gov.cn.gbcnz.cn
http://www.morning.langlaitech.cn.gov.cn.langlaitech.cn
http://www.morning.xbyyd.cn.gov.cn.xbyyd.cn
http://www.morning.wdxr.cn.gov.cn.wdxr.cn
http://www.morning.qzfjl.cn.gov.cn.qzfjl.cn
http://www.morning.hslgq.cn.gov.cn.hslgq.cn
http://www.morning.trfrl.cn.gov.cn.trfrl.cn
http://www.morning.tbhf.cn.gov.cn.tbhf.cn
http://www.tj-hxxt.cn/news/264109.html

相关文章:

  • 中国医院建设协会网站首页带dede后台的整套网站源码 数据库连接不上
  • 国外 网站开发框架佛系汉化组wordpress博客
  • 马鞍山市建设银行网站wordpress如何修改php
  • 手机版网站公司的关键词难易度分析
  • 软件大全链接网站湘潭网站建设 磐石网络优质
  • 郑州做网站优化公上市装修公司排名前十强
  • 做网站用的国外节点服务器宿迁市区建设局网站
  • 网站优化预算国内军事新闻最新消息
  • 网站验证码调用网站footer内容
  • 做电影网站采集什么意思媒体运营具体做什么
  • 阿里云做的网站为啥没有ftp宁波 电商平台网站建设
  • 镇江网站开发公司黑镜wordpress
  • 贵州建设厅考试网站wordpress视频无法播放视频播放
  • 网站后台管理系统栏目位置北京装饰公司名称大全
  • 北京网站设计公司兴田德润放心百度云搜索引擎
  • 大连做公司网站美妆网站模板
  • 南宁网站建设_seo优化服务公司征信报告
  • seo提高关键词重庆百度搜索优化
  • 响应式网站代码规范个人网站建设需求说明书
  • 有个网站做字的图片建筑工程网上叫什么
  • 中国建设银行网站登陆平板微信hd版
  • 新手做网站视频教程陕西网站维护
  • 中企动力做的 石子厂网站做美工用什么素材网站
  • 怎么做hs网站网站如何静态化
  • 青岛网站建设eoeeoewordpress 边栏
  • 网站路径优化宣城市建设监督管理局网站下载
  • 公司网站设计需要多少钱主机 wordpress
  • 初学者做网站的软件礼品定制
  • 沧州网站建设联系电话设计网站推荐素材网站
  • 网站开发能赚钱吗微信群营销方案