I have a Google App Engine site, with multiple pages that are rendered using templates. I’d like to have a hello, user!-type greeting on the header of every page. I can call users.get_current_user().nickname()(or something like) on every handler and add that to the template values dictionary, but I was wondering if there was a cleaner way to do it – perhaps call it directly from the template?
I have a Google App Engine site, with multiple pages that are rendered using
Share
I don’t know of a built-in way to access that from a template, but I agree with you that I certainly wouldn’t want to have to re-type the code in every handler.
If all your views are children of one main handler then you can stick the code in that main handler and be done with it, e.g.:
Source code for a full example.