Questions tagged [templatetag]
37 questions
22
votes
4 answers
Use a remote stylesheet inside a template tag (with shadow dom)
I am trying to make a semi-resuseable widget but I am running into a problem. I am trying to encapsulate a some CSS code inside a shadow root so that it does not affect the rest of the webpage but this CSS is used across multiple widgets so I am…

dtracers
- 1,534
- 3
- 17
- 37
21
votes
2 answers
html template tag and jquery
I've got this situation where I'm trying to use the tag in my html source:
15
votes
1 answer
Put the result of simple tag into a variable
this works:
{% get_option 'payment_conditions' '' true %}
It calls a function with 3 parameters and it returns a string: "I am the conditions". Great.
What I want to do now is to put this in a IF statement. So to do this, I need the value into a…

jobima
- 5,790
- 1
- 20
- 18
7
votes
7 answers
Is there a pythonic way of knowing when the first and last loop in a for is being passed through?
I have a template in which I placed, let's say 5 forms, but all disabled to be posted except for the first one. The next form can only be filled if I click a button that enables it first.
I'm looking for a way to implement a Django-like forloop.last…

Gerard
- 9,088
- 8
- 37
- 52
6
votes
1 answer
Polymer 1.0: Using template dom-repeat inside paper-menu elements to display iron-pages on selection
Using Polymer 1.0, I have created a paper-drawer-panel layout. In the drawer I have a menu using paper-menu with paper-items which are bound to the iron-pages. I took this example from Content Switcheroo with Core-Pages -- Polycasts #09 and…

Erik Höhmann
- 522
- 4
- 16
5
votes
2 answers
django template - parse variable inside string variable
I'm pulling a dynamic content(from a database) to a template. You can think of this as some simple CMS system. The content string contains a template variable. Like this one (simplified case):
vars['current_city'] = "London"
vars['content'] = 'the…

robertzp
- 1,415
- 1
- 13
- 10
4
votes
2 answers
Why using django TemplateTag tag?
I have been reading some django code recently and the tag Templatetag is heavily used :
{% templatetag openblock %} block page_title {% templatetag closeblock %}
Page Title
{% templatetag openblock %} endblock page_title {% templatetag…

user1946989
- 377
- 1
- 4
- 16
4
votes
2 answers
Django Template tag to allow bold and italic elements
Django has a template tag that allows you to remove certain html tags from being displayed in stored data.
The django documentation gives an example. Any b or span tags are removed.…

Joe J
- 9,985
- 16
- 68
- 100
3
votes
3 answers
How to embed a tag within a url templatetag in a django template?
How do I embed a tag within a url templatetag in a django template?
Django 1.0 , Python 2.5.2
In views.py
def home_page_view(request):
NUP={"HOMEPAGE": "named-url-pattern-string-for-my-home-page-view"}
variables = RequestContext(request,…

X10
- 17,155
- 7
- 30
- 28
3
votes
5 answers
Django template tag + template with user.is_authenticated doesn't work
I have a strange problem, in my settings file everything is enabled that needs to be enabled for user.is_authenticated use in a template.
I have the following template tag code:
from django import template
from progmatic.cms.models import…

Bloeper
- 347
- 2
- 3
- 13
3
votes
6 answers
How to render form.as_table in multiple columns
I am using a model form, and I have rendering that form in the template as below.
{{form.as_table}}
But the problem is, its rendering all the fields as rows. Since my model contains more than 200 rows,
when its showing the…

sandeep
- 3,061
- 11
- 35
- 54
1
vote
3 answers
Django plaintext template
I'm currently writing a template which mostly outputs my fields and it's contents from the database as plaintext so that it can be downloaded (supposed to be a configuration file for ltsp) and I'm in a bind.
I often do things like this:
{% for…

wagner-felix
- 855
- 3
- 9
- 19
1
vote
0 answers
Django String trimming breaks encoding using truncatechars template tag
this is the text used to trim in the list view
my_var = une startup (jeune pousse, société )
and use this template tag for trimming
{{my_var | striptags | truncatechars:"50" }}
I got this output
une startup (jeune pousse, soci&eacu...
expected…

Shihabudheen K M
- 1,347
- 1
- 13
- 19
1
vote
1 answer
How do I use the django template tag in the css tag?
I tried to use the forloop.last template tag
{% for card in cardlist.card_set.all %}
{% if forloop.last %}
{{ card.title }}
{% else %}

Nouveau
- 373
- 2
- 3
- 7
1
vote
1 answer
django - how to pass multiple values to a templatetag
I am trying to pass multiple parameters to my template tag:
@register.filter
def val_color(val, min_val):
if val >= min_val:
return 'red'
return 'black'
template:
{% for x in data.vals %}

max
- 9,708
- 15
- 89
- 144