django-template-filters Questions

10

Solved

Here's my custom filter: from django import template register = template.Library() @register.filter def replace(value, cherche, remplacement): return value.replace(cherche, remplacement) And, h...

3

Solved

I am trying to use django's built in 'default' filter using this code <title>{{ title|default :"nothing" }}</title> But it gives me the following exception django.template.b...

2

Solved

I used default_if_none as shown below: <input type="text" name='username' value="{{ value|default_if_none: '' }}"> But, I got the error below: django.template.exceptions...

19

Solved

How do I get the domain name of my current site from within a Django template? I've tried looking in the tag and filters but nothing there.

2

Solved

My filter is not being registered and not sure where it's getting tripped up. In test/templatetags __init__.py test_tags.py test_tags.py includes from django import template register.filter(...
Atropos asked 2/8, 2014 at 1:18

3

Solved

In the following django template variable .Is it possible to remove the html tags via django template filters {{myvar|safe}} The following would output an html like <div>sddfdsfsdfsdf ...
Gassman asked 7/7, 2011 at 6:46

4

Is there a way to get multiple digits of a given number within a django template? For example: {{ some_num|get_digit:2 }} will give you the second right most digit. For 1224531 it would be 3 ...
Visage asked 11/1, 2012 at 23:28

4

Solved

I got an article app and trying to make a custom filter, I have a directory called templatetags in article app, and a tags.py within that directory, here is the directory structure. -manage.py(f) ...
Lorraine asked 9/4, 2011 at 11:21

2

Solved

My template renders the tag {{ test.date}} in the following format - 2015-12-15T23:55:33.422679 When I try to format it using django's built in template tag date, it doesn't display anything. Va...
Myall asked 17/12, 2015 at 10:21

4

Solved

I want to display a list of objects in a Django generic display view ListView class. And, to make it prettier, I try to sort it in alphabetic order. So, I use the built-in dictsort tag to sort the ...
Macbeth asked 2/2, 2014 at 14:9

4

Solved

I have a variable that contains JSON I need to pass into a template. I'm defining it as a variable and then passing it into the template successfully. However, I need the format to replace the quot...
Stroll asked 8/6, 2011 at 22:46

5

Solved

I have a model field, which stores a list of URLs (yeah, I know, that's wrong way) as url1\nurl2\nurl3<...>. I need to split the field into an array in my template, so I created the custom fi...
Job asked 29/11, 2011 at 20:50

1

Solved

I can't figure out how to send multiple arguments into custom template filter. The problem is that I use template variables as an arguments. CUSTOM TEMPLATE FILTER @register.filter def is_schedu...
Meunier asked 5/11, 2016 at 17:0

1

Solved

This hopefully is a pretty easy question. My endgoal is to be able to view my database entries in a table which I can sort via the column headers. I have read the documentation on cycle tags, but d...

1

Solved

I have a "create new object" button in a template file. I want to include the button in several places at my website, but I want to include the template with a link. I've tried: {% includ...
Interpenetrate asked 15/4, 2015 at 12:26

2

Solved

Is it possible to access the current User (i.e. user in the template context) from a custom template filter? Obviously I can pass the user in as an argument, but if it's possible to just grab the ...
Anonymous asked 13/7, 2011 at 18:5

2

Solved

How to ensure that all html-tags were closed? The problem arises because I want create some sort of excerpt for every article. For example someone writes an article like this: Hi everyone, I'm jus...

1

Solved

Is there a way to access a JavaScript variable in django template code as shown below: var tags_v1 = '{{ form.tags_1.value }}'; tags_v1 = tags_v1.split('{{ form.value_delim }}'); tags_v1 = tags_v1...

1

Solved

There is a forloop in java where i can tell where to start and where to end: for(int i=10;i<array.length;i++){ } but how can i implement this int i=10 in django template? How can i set the ...

1

Solved

I made this custom filter to check if an image exists or not: from django import template from django.core.files.storage import default_storage register = template.Library() @register.filter(nam...
Transcendence asked 21/8, 2013 at 18:0

1

Solved

The static files (css, js, images) are serving from local whilst media files (uploaded images and videos) are on Amazon S3 server in my project. I can upload media files to Amazon S3 without any p...
Discontented asked 18/7, 2013 at 10:33

2

Solved

I am trying to pass a dictionary to a django template. In the django view, the variable is initialized and passed as such: foo = {'a':'b'} ... return render(request, 'template.html', {'foo': str(f...
Georgeanngeorgeanna asked 22/3, 2013 at 12:14

2

Solved

Is there a template filter in django that will trim any leading or trailing whitespace from the input text. Something like: {{ var.example|trim }}
Prophesy asked 28/4, 2012 at 6:35

2

Solved

Django beginner question. I have the following model: class Leg(models.Model): startpoint = models.CharField(max_length=50, help_text="examples: 'Smith Elementary' or 'riders' houses'; less than ...

1

I have seen enough number of examples that allow me to declare a new variable inside a template and set its value. But what I want to do is to update the value of a particular variable inside the t...
Hoad asked 4/7, 2012 at 8:1

© 2022 - 2024 — McMap. All rights reserved.