后台管理布局之模板继承
2017-08-26 17:38
387 查看
后台管理布局中分-----上-------左 ===== 右=====默认的管理界面 左侧跟上方的区域不做任何变动对于右侧区域 支持滚动 css添加
overflow: scroll;
对于右侧区域的内容 进行继承
父级的base.html添加模板语言
{% blockcontent %}{% endblock %}子文件使用extends直接继承
{% extends "base.html" %}{% block content %}<form action=""><p><input type="text">账号</p></form>{% endblock %}
如果父级base.html有文件内容 则会被覆盖掉
完整代码内容如下:
urls.py
"""s17day17 URL ConfigurationThe `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.11/topics/http/urls/ Examples:Function views1. Add an import: from my_app import views2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')Class-based views1. Add an import: from other_app.views import Home2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')Including another URLconf1. Import the include() function: from django.conf.urls import url, include2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))"""from django.conf.urls import urlfrom django.contrib import adminfrom app01 import viewsurlpatterns = [url(r'^admin/', admin.site.urls),url(r'^index/', views.index),url(r'^addArticle/', views.addArticle),]views.py文件内容
from django.shortcuts import render,HttpResponseimport datetime# Create your views here.def index(request):t=datetime.datetime.now()a='<a href="baidu. com">asd</a>'word="I come from a"l=[1,1,2,3]# return HttpResponse("HELLO")return render(request,"后台管理布局.html",locals())def addArticle(request):return render(request,"addArticle.html")base.html文件内容
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Title</title></head><style>.header {width: 100%;height: 48px;background-color: darkgrey;position: fixed;top: 0;left: 0;}.left {width: 200px;position: absolute;top: 48px;left: 0;bottom: 0;background-color: greenyellow;}.right {position: absolute;top: 48px;bottom: 0;left: 200px;right: 0;overflow: scroll;background-color: beige;}.left a {display: inline-block;width: 100%;padding: 20px;background-color: lightskyblue;color: black;}</style><body><div class="header"></div><div class="box"><div class="left"><a href="/addArticle/">添加文章</a></div><div class="right">{% block content %}{% endblock %}</div></div></body></html>addArticle.html内容
{% extends "base.html" %}{% block content %}<form action=""><p><input type="text">账号</p></form>{% endblock %}后台管理布局.html 即index文件
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Title</title></head><style>.header {width: 100%;height: 48px;background-color: darkgrey;position: fixed;top: 0;left: 0;}.left {width: 200px;position: absolute;top: 48px;left: 0;bottom: 0;background-color: greenyellow;}.right {position: absolute;top: 48px;bottom: 0;left: 200px;right: 0;overflow: scroll;background-color: beige;}.left a {display: inline-block;width: 100%;padding: 20px;background-color: lightskyblue;color: black;}</style><body><div class="header"></div><div class="box"><div class="left"><a href="/addArticle/">添加文章</a></div><div class="right"><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1><h1>xp</h1></div></div></body></html>
相关文章推荐
- 后台管理布局之模板继承2 补充 继承拼接
- 精美的后台管理界面模板和布局
- 25 个精美的后台管理界面模板和布局
- 25 个精美的后台管理界面模板和布局
- 25 个精美的后台管理界面模板和布局
- 25 个精美的后台管理界面模板和布局
- 25 个精美的后台管理界面模板和布局
- 25 个精美的后台管理界面模板和布局
- 25 个精美的后台管理界面模板和布局
- 地磅称量系统之(30~34)从我定义的界面模板中继承窗体并且完善它的的界面编辑控件布局展示主界面的运行效果图
- 用类的继承关系(重写父类的方法)实现简易后台代码模板
- HTML 后台管理页面布局
- HTML5后台管理模板
- asp.net mvc+jquery easyui开发实战教程之网站后台管理系统开发4- 后台模板html页面创建
- 12个非常不错的免费HTML后台管理模板
- 【网站管理5】_讲解网站后台SEO优化和如何修改关键字以及关键词布局
- 基于Extjs 4.2的通用权限管理系统,通用后台模板,EF+MVC+Extjs 4.2
- 管理后台比较好的U模板
- 50 个漂亮的后台管理界面模板
- 使用前端后台管理模板库admin-lte