开发者

MasterPage like concept in python

开发者 https://www.devze.com 2022-12-16 06:06 出处:网络
We are developing a web based application in python on google app engine platform. I have different pages in web site. What I want is to have a master page like functionality like we have in asp.net w

We are developing a web based application in python on google app engine platform. I have different pages in web site. What I want is to have a master page like functionality like we have in asp.net where I have just on template an开发者_高级运维d all other pages will use that. How can I do this? I am a beginner in python


If you're using Django (or at least Django templates), Django template inheritance may be what you're looking for.


I think you are exactly looking for "template extending".

  1. Create base/master html file in "templates" folder.

    This will be base/master file where all theme css,js , html layout tags exists.

  2. Add place holders for child html "content" in above base/master html

    {% block content %} {% endblock %}

  3. Add following code line in "child" template to use above base/master html

    {% extends 'path_to_base_html/base.html' %} {% block content %} Child html {% endblock %}

Thanks to this nice tutorial, http://tutorial.djangogirls.org/en/template_extending/index.html

0

精彩评论

暂无评论...
验证码 换一张
取 消