How to load a page starting with a specific section id using template.render () with python, jinja2

Here's the python code:

template = jinja_environment.get_template('index.html') self.response.out.write(template.render(template_values)) 

However, I would like to download index.html, starting with the anchor tag below:

(where this anchor tag is in the index.html file)

 <section> id="home"> 

How do I change python code for this?

As you can tell, I am new and am currently working on Google App Engine tutorials.

Thank you for your help!

+4
source share
2 answers

I think you are a little confused. With jinja2 and Python code, all you can achieve is create a server-side page. If you want to go to a specific section on this page, you must do this on the client side using JavaScript ( example ).

+3
source

Suppose you want to access your page on the page / your page and in the home section. You can do this with a redirect:

 YourHandler(RequestHandler): def get(self): self.redirect("/yourpage#home") 

So, you need to put the section identifier immediately after the "#" sign.

It worked for me, at least in Google Chrome.

+2
source

All Articles