Re: use site's templates

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: use site's templates

dupakoor kannan
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

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CADiZb_fDFdVzs2b3rt54BFa5_jxCiWs01NPHtnmhrZ%2BCEfJp7w%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: use site's templates

RONAK JAIN
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 


On Fri, Aug 16, 2019 at 12:01 AM dupakoor kannan <[hidden email]> wrote:
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

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CADiZb_fDFdVzs2b3rt54BFa5_jxCiWs01NPHtnmhrZ%2BCEfJp7w%40mail.gmail.com.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BAqMUeejwHwpH6o%3DDYobG2GkqFPQ0WJPm2dOE08stK%3DtT_-%3Dg%40mail.gmail.com.