I'm making a Flask application. I have a login area, a blogs area. If I want to get user's login, I'll render login template. But this doesn't render the blog template that has to be displayed below the login area. :/
I'll try to make it clearer:
{% block login %} {% endblock %}
blah blah
{% block blog_display %} {% endblock %}
Now i have a login.html
which extends this, and goes into login block. I have a blogs.html
which goes into blog_display
. How to I render both? When I do render_template()
, i can call it on only one of the login.html
or blogs.html
.
Please help me out. I'll give more details if you ask for it.
You may be thinking about layouts the wrong way. Your layout is the most generic of your templates, not your most complex one. If you need little self-contained pieces of functionality then write them up just as they are and
include
them where they are needed.That is to say, if you want something like this:
And you also want to have a stand-alone login page like this:
Then create a login partial and
include
it where you need it.Example
templates/partials/login.html
templates/your_base.html
templates/login.html
templates/blog.html
Sean's answer works good, but if you don't want to extend blocks you can pick up a simpler solution, which i prefer more.
Just use it anywhere you need to include the template