【发布时间】:2013-08-28 09:15:37
【问题描述】:
我有一个包含用户信息和 IP 的数据库。我想做的是动态创建,然后用他们的 IP 打开一个 *.vnc 文件。
在我的views.py 文件中,我有这个:
def view_list(request):
template_name = 'reader/list.html'
cust_list = xport.objects.all()
#if request.method == 'POST':
#<a href=link to created *.vnc file>Connect to client</a>
return render(request, template_name, {'xport': cust_list})
注释掉的部分正是我一直在玩的以及我目前认为我需要做的事情。
我的模板文件是list.html,看起来像这样:
{% extends "base.html" %}
{% load url from future %}
{% block content %}
<h1> Customer List </h1>
<ul>
{% for c in xport %}
{% if c.ip %}
<li>{{ c.firstName }} {{ c.lastName }}</li>
<form method="POST" action=".">{% csrf_token %}
<input type="submit" name="submit" value="Create VNC to {{ c.ip }}" />
</form>
{% endif %}
{% endfor %}
</ul>
{% endblock %}
我想做的是单击“创建 VNC”按钮,然后创建并打开 *.vnc 文件。
【问题讨论】:
标签: python html django post vnc