Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use linebreaksbr filter method in Django view?

linebreaksbr is Django's template filter method.

Such as:

<td>{% filter linebreaksbr %}{% render_result result %}{% endfilter %}</td>

How to use it in view.py?

That means I want to get the same data result from view and download to csv file.

like image 225
cho Avatar asked May 27 '13 01:05

cho


People also ask

Can I use filter () in Django template?

Django Template Engine provides filters which are used to transform the values of variables;es and tag arguments. We have already discussed major Django Template Tags. Tags can't modify value of a variable whereas filters can be used for incrementing value of a variable or modifying it to one's own need.

What does {% %} mean in Django?

{% extends variable %} uses the value of variable . If the variable evaluates to a string, Django will use that string as the name of the parent template. If the variable evaluates to a Template object, Django will use that object as the parent template.

What is Forloop counter in Django?

A for loop is used for iterating over a sequence, like looping over items in an array, a list, or a dictionary.


1 Answers

To use it in your views, you can do:

from django.template.defaultfilters import linebreaksbr

and in then

linebreaksbr(varname)

where varname is the variable.

Here is the source

like image 67
karthikr Avatar answered Oct 11 '22 00:10

karthikr