K
K
KIN19912019-03-08 17:59:26
Django
KIN1991, 2019-03-08 17:59:26

How to include a template from a required app in Django?

Good afternoon, actually there is a project with such file structure

project/
    apps/
        app1/
            templates/
                list.html
        app2/
            templates/
                list.html
        app3/
            templates/
                index.html

I need to include app2/templates/index.html in the app3/templates/index.html file. Is it possible to somehow strictly specify in the include tag what to look for first of all in the app2 application? Is there a way to do without absolute paths?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2019-03-08
@KIN1991

No, the search will be performed in the order the apps are listed in INSTALLED_APPSand will stop as soon as the first match is found. The standard way is to create subdirectories in templates with the same name as the application:

app1/
  templates/
    app1/
      list.html
app2/
  templates/
    app2/
      list.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question