在Django中提供外部模板 [英] Serve external template in Django

查看:56
本文介绍了在Django中提供外部模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做类似的事情

  return render_to_response( http://docs.google.com/View?id = bla,args)

并使用django参数提供服务。 Django不喜欢这样(它会在非常特定的位置查找模板)。



最简单的方法是什么?现在,我正在考虑使用urllib将页面保存到服务器上的本地位置,然后使用指向该服务器的模板进行服务。



注意:我不是在这里寻找特别可扩展的内容,我意识到上面的建议有点脏。

解决方案

以字符串形式读取模板,然后自行渲染。 / p>

I want to do something like

return render_to_response("http://docs.google.com/View?id=bla", args)

and serve an external page with django arguments. Django doesn't like this (it looks for templates in very particular places).

What's the easiest way make this work? Right now I'm thinking to use urllib to save the page to somewhere locally on my server and then serve with the templates pointing to there.

Note: I'm not looking for anything particularly scalable here, I realize my proposal above is a little dirty.

解决方案

Read the template in as a string and render it yourself.

这篇关于在Django中提供外部模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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