python - Django display data from mysql to HTML table -
i have problem when use django display data mysql html table. view:
@login_required(login_url='/login') def data_to_list(request): data_list = es_device.objects.all() context = {'data_list': data_list} #return render(request, 'logfile/data_bi.html', context) return render_to_response('logfile/data_bi.html',locals())
model:
class device(models.model): device_name = models.charfield(max_length=200, verbose_name='aaa', default=none) device_type = models.charfield(max_length=200, verbose_name='bbb', default=none)
url:
url(r'^data_bi', data_to_list)
html:
<th>..</th> ... item in data_list <tb>item.device_name</tb> <tb>item.device_type</tb> end ...
but result shows table head, no 's results, why happen?how solve this? help!
change template html this:
{% item in data_list%} <tb>{{item.device_name}}</tb> <tb>{{item.device_type}}</tb> {% endfor %}
Comments
Post a Comment