[Django]-Which Django template layout is better?

3đź‘Ť

âś…

It likely depends on your purposes. For most purposes, the first example will work best. Your base.html will include a lot of site-specific stuff that you won’t want to repeat across each and every base_app.html template.

If you are making reusable apps that you want to share with other people, then it’s probably best to use the second example. This way someone that uses your app won’t need a base.html template to get your app up and running. It’s a little more “all-inclusive”.

This is basically what those docs are saying. The general advice is use the first method unless you’re open-sourcing it and putting it on PyPi or something.

Even if you want to make a package reusable for your use only (i.e. use in multiple projects you’re working on), I’d go with the first method. You can make it so you always have a base.html in your template directory.

👤Alex

Leave a comment