Re: use site's templates

8 views
Skip to first unread message

dupakoor kannan

unread,
Aug 15, 2019, 2:31:41 PM8/15/19
to django...@googlegroups.com
Hi,

I am trying to use a Django tip from stackoverflow https://stackoverflow.com/a/946397/4037275 

I have static css style sheets (static). I will use {% load static %}. Can I use this template approach in extending templates {% extends "project/base.html" %}

Can you give me few other examples of using this? 


Copied from the above stackoverflow link.

There's a set of custom tags I use all over my site's templates. Looking for a way to autoload it (DRY, remember?), I found the following:

from django import template
template.add_to_builtins('project.app.templatetags.custom_tag_module')

If you put this in a module that's loaded by default (your main urlconf for instance), you'll have the tags and filters from your custom tag module available in any template, without using {% load custom_tag_module %}.

The argument passed to template.add_to_builtins() can be any module path; your custom tag module doesn't have to live in a specific application. For example, it can also be a module in your project's root directory (eg. 'project.custom_tag_module').

Thank you

Kannan

RONAK JAIN

unread,
Aug 15, 2019, 2:49:18 PM8/15/19
to django...@googlegroups.com
Hey ,


You can use for the load your base.html 

 {% extends "project/base.html" %}

I will give some example for better understanding so, if you are trying to Extend your html file in your index.html file so, you can write simply according to me:
{% load static %}
{% extends 'base.html' %}

{% block content %}



{% endblock %}


I hope this is helpful...

Thanks 


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CADiZb_fDFdVzs2b3rt54BFa5_jxCiWs01NPHtnmhrZ%2BCEfJp7w%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages