Django: Overriding AND extending an app template

前端 未结 6 2033
北荒
北荒 2020-12-02 18:05

If you want to override a template coming with an app in django (in app/templates/app/) you create a template of the same name in another directory, which the template loade

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-02 18:56

    In the Django wiki, Simon Willison presents a trick to achieve the "self-extending template" effect. It isn't directly applicable if you're using the app_directories template loader, though.

    Symlinking apps' templates directories inside a new directory might do a trick.

提交回复
热议问题