I have a Django template that looks like this:
<div id="objects">
<b>Ingredients:</b>
<small>
{% for obj in result.object.list_objects|slice:":10" %}
.{{ obj }}
{% endfor %}
......
</small>
</div>
I am trying to output a simple list but when I loop through these elements in the template, the output is unfortunately in single quotes for each object. I am new to Django templates and have tried using a few methods like safe
and escape
. But the single quotes remain. Is there a way in Django to strip out that specific character when loading the data?
__str__
methods for your model? (b) Why are you passingresult
into your template? IMO you should slice and dice the list of objects in your view code and pass the list of ten objects you want directly to your template. (c) Is this your exact code? I suspect it's not, since yourlist_objects
contains a typo. Please edit your question and paste exactly the code you are using. A single character can make a big difference. – Chris