12

I am creating a fairly large application using Flask and Jinja. Flask recommends separating large applications into smaller units using Blueprints. If I have a base layout for my entire application/website, how can I extend this from templates within my blueprints?

Kyle Johnson
  • 1,515
  • 1
  • 16
  • 24

1 Answers1

22

You simply write name of the base template layout and Flask will find it if it exists in app's templates folder and then in blueprint's templates folder.

    {% extends 'template_name.html' %}

If it exists inside a folder in templates folder then

    {% extends 'folder_name/template_name.html' %}

If there are two templates with same name in app's templates folder and blueprint's template folder, then template in app's templates folder will get priority.

See this question for more info flask blueprint template folder

Flask automatically finds templates for you if they are placed at right positions.

Community
  • 1
  • 1
codecool
  • 5,148
  • 4
  • 24
  • 35