templates extends from project to apps

Asked

Viewed 14 times

0

I have a project created from startproject ... command where in the structure of it, I created a templates folder, in which, I wish to have templates htmls bases, ie extending them to the templates of my apps. Is it possible? if yes how can I do? I read here in some post, that I should do it from a master app and not from the project, that’s right?

1 answer

0

I found out after reading a lot of articles on the subject. So: for a extends from the project, just include in Settings.py in the TEMPLATE configuration the following configuration 'DIRS': [os.path.Join(BASE_DIR, 'site/templates')]... where "site" is your project. Next, create a folder named "templates" in the structure of your project and a new folder with the name of your app, for example "blog", thus: "blog templates". Done, now I can have a base.html and used in my apps using {% extends "blog/layout.html" %}.

For more details, this font helped me a lot: https://docs.djangoproject.com/pt-br/2.2/howto/overriding-templates/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.