Django直接链接到html模板 [英] Django urls straight to html template

查看:303
本文介绍了Django直接链接到html模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

学习django& python。

Learning django & python.

在完成教程之后,只需设置一个新的网站。现在为了争论的缘故,我想添加一堆关于我们,常见问题的基本HTML页面与非常有限的动态元素你会继续在我的urls.py文件中为每一页写一条新行?或者是他们的一些简洁的方法来将所有* * .html直接映射到相关的.html文件?

Just set up a new site after doing the tutorial. Now for arguments sake say I want to add a bunch of About us, FAQ basic html pages with very limited dynamic elements do you go ahead and write a new line in my urls.py file for each page? or is their some neat way to say map all * *.html to the relevant .html file directly?

一般来说,即使它需要一个视图,我必须在每个页面的url.py文件中写一条新行?

In general even if it does require a view will I have to write a new line in the url.py file for every page?

推荐答案

只要有一些唯一标识部分URL,您不需要在每个直接模板网址的urls.py中创建一个条目。

As long as there is some uniquely identifying section in the URL, you will not need to create an entry in urls.py for each direct-template url.

例如,您可以说所有以.html结尾的网址引用模板中的直接文件。

For example, you could say that all urls ending in ".html" are referencing a direct file from the templates.

urlpatterns = patterns('django.views.generic.simple',
    (r'(.+\.html)$', 'direct_to_template'),
    # ...
)

查看 http://docs.djangoproject.com/en/1.2/ref/generic-views/#django-views-generic-simple-direct-to-template 为deta ils。

Take a look at http://docs.djangoproject.com/en/1.2/ref/generic-views/#django-views-generic-simple-direct-to-template for details.

这篇关于Django直接链接到html模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆