table = [
['header1', 'header2', 'header3', 'header4'],
['value1.1', 'value2.1', 'value3.1', 'value4.1'],
['value1.2', 'value2.2', 'value3.2', 'value4.2']
]
<table>
{% for v1, v2, v3, v4 in table %}
{% if forloop.first %}
<tr>
<th>{{ v1 }}</th>
<th>{{ v2 }}</th>
<th>{{ v3 }}</th>
<th>{{ v4 }}</th>
</tr>
{% else %}
<tr>
<td>{{ v1 }}</td>
<td>{{ v2 }}</td>
<td>{{ v3 }}</td>
<td>{{ v4 }}</td>
</tr>
{% endif %}
{% endfor %}
</table>
table = [('header1', 'header2', 'header3', 'header4')]
table += Model.objects.all().values_list('value1', 'value2', 'value3', 'value4')
context['table'] = table
function drawChart(chartData, lineChartId) {
var data = new google.visualization.DataTable();
data.addColumn('date', 'Time of Day');
data.addColumn('number', 'KWR');
data.addColumn('number', 'BSR');
data.addRows(chartData);
var options = {
colors: ['#000000','#ff9000'],
hAxis: {
format: 'M/d/yy',
gridlines: {count: 10}
},
vAxis: {
direction: -1
}
};
var chart = new google.visualization.LineChart(document.getElementById(lineChartId));
chart.draw(data, options);
}
function unpackObj(obj, user={}) {
for ( var property in obj ) {
if ( obj.hasOwnProperty(property) ) {
if (typeof obj[property] === 'object' && ! Array.isArray(obj[property])) {
user = unpackObj(obj[property], user);
} else {
user[property] = obj[property]
}
}
}
return user
}
{
"id": 9,
"url": "http://127.0.0.1:8000/api/users/yufghbfcv/",
"first_name": "dsdsds",
"last_name": "htghtghgfhgfh",
"username": "yufghbfcv",
"email": "dsuhd@mail.com",
"birthday": "2017-12-18",
"is_active": true,
"address": {
"zip_code": "123456",
"country": "wewedasdscxc",
"city": "xcxcxcx",
"district": "dadada",
"street": "cxcxc"
},
"groups": [],
"date_joined": "2017-10-20 20:31:30",
"last_update": "2017-11-28 13:26:55"
}