Reputation: 417
I passing the list of tuples from view to template.While printing the each element of the tuple if spaces is found then Django automatically removes the character after spaces. Here is my view.py
def index(request):
user_statuses = get_user_status()
user_statuses.sort(key=lambda user_statuses:
datetime.datetime.strptime(user_statuses[0], '%Y-%m-%d'),reverse=True)
return render(request, 'view_status.html', {'lists': user_statuses
})
Here is my template:
<table>
<thread>
<th bgcolor="#35a5f0">
<td bgcolor="#35a5f0">Date</td>
<td bgcolor="#35a5f0">Project</td>
<td bgcolor="#35a5f0">Release</td>
<td bgcolor="#35a5f0">Feature</td>
<td bgcolor="#35a5f0">Module name</td>
<td bgcolor="#35a5f0">Hours spent</td>
<td bgcolor="#35a5f0">Comment</td>
</th>
</thead>
<tbody>
{%for list in lists%}
<tr>
<td><input type="checkbox" name="vehicle"></td>
{%for i in list%}
<td><input type="text" value={{i}}><br></td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
My List of tuple is as below:
[(u'2017-05-02', u'Web Design', u'1', u'UT', u'Redundancy', u'1', u'Add extra information'), (u'2017-05-01', u'Web Design', u'1', u'UT', u'Redundancy', u'1', u'Add extra information')]
As u can see characters after the spaces are ignored. Please help.
Upvotes: 0
Views: 147