开发者

does django has a method like 'render_template' in gae (google app engine)

开发者 https://www.devze.com 2023-01-28 04:52 出处:网络
This is my gae code: class BaseRequestHandler(webapp.RequestHandler): def render_template(self, filename, template_values={}):

This is my gae code:

class BaseRequestHandler(webapp.RequestHandler):
    def render_template(self, filename, template_values={}):
        values={
        }
        template_values.update(values)
     开发者_运维知识库   path = os.path.join(os.path.dirname(__file__), 'templates', filename)
        self.response.out.write(template.render(path, template_values))


class CounterHandler(BaseRequestHandler):
    def get(self):
        self.render_template('counters.html',{'counters': Counter.all()})

Does django has this method?

How to make a method like render_template in django?


Yes, it's called render_to_response, and is explained here:

http://docs.djangoproject.com/en/dev/topics/http/shortcuts/

0

精彩评论

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

关注公众号