开发者

Django: separate template dir for model

What's the point of using template structure like this:

templates/
    app/
        article_view.html # or view_article.html
        category_view.html

vs

templates/
    app/
        article/
            view.html
        category/
            view.html

It's easier to fi开发者_StackOverflow社区nd particular template with second approach, but I almost don't see any apps using it. Why?


This depends on the scale of the project; a small-scale thingie could be more easy to handle with the first approach, while a project with several hundred template files could use a better folder structure, i.e. the second approach


Generally speaking, templates are associated with views rather than models. A view pulls in one or more models as needed, then renders the appropriate template. Since an app usually consolidates views in one file, the template to app correspondence works well enough.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜