In Python Django, the actual application scheme for rendering the sequence of tuples is generally to render a relative dataset. The following article mainly introduces how to render the template in Python Django. I hope you will gain some benefits, the following is a detailed description of the article.
A general method of rendering a template is to render a dataset. Now we need to render the content output after a field is split.
View Layer Code:
- room = Agente.objects.get(id = t_id)
- all_agent = room.package_dbname
- output = all_agent.split(";")
The serial number is composed of agent number_real name. py
- return render_to_response('moni/tagent.html',{'s_h':room,'output':output})
Template Layer Code:
- {% for type in output %}
- <tr bgcolor="#EBF2F9" align=center>
- <td align="center">
- <label>{{type}}</label>
- </td>
The Traversal method is actually the same as the method written in PY! One problem is that the last column is null during split. Filter required
Solution:
- result = output[0:len(output)-1]
In this way, you can split the dataset to be traversed!