Django view - load template from calling app's dir first

前端 未结 3 1340
甜味超标
甜味超标 2020-12-04 17:51

I try to keep a somewhat consistent naming scheme on my HTML templates. I.e. index.html for main, delete.html for delete page and so forth. But the app_directories

3条回答
  •  攒了一身酷
    2020-12-04 18:38

    The app_loader looks for templates within your applications in order that they are specified in your INSTALLED_APPS. (http://docs.djangoproject.com/en/dev/ref/templates/api/#loader-types).

    My suggestion is to preface the name of your template file with the app name to avoid these naming conflicts.

    For example, the template dir for app1 would look like:

    templates/
        app1_index.html
        app1_delete.html
        app1_add.html
        app1_create.html
    

提交回复
热议问题