In terms of best practices for Django templates, I recommend that you
try to use template inheritance extensively, in similar ways as when
you would use subclassing:

- Create a base.html template with everything that appears in all your
pages (common header and footer, generic html headers...).
- Create extension "hooks" in the form of {% block %} in any place you
would like to override in specific pages
- Extend that template for any page in your application
- Don't be afraid to create multiple levels of inheritance, e.g. sub-
templates of base for different sections of your site that require a
different layout.
- In many places where you could use {% if %} to create variants for a
page, you can do it more cleanly with inheritance

Besides the typical {% extends "base.html" %} (fixed template name), a
powerful option is {% extends variable_name %} where you can pass as a
context to your template the name of the "super-template" you want to
use.




On 8 Gen, 21:21, Mo Mughrabi <mo.mughr...@gmail.com> wrote:
> I'm wondering what would be the best practice for templating in django.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to