0
我有一個包含用戶信息和IP的數據庫。我想要做的是動態創建,然後用他們的IP打開一個* .vnc文件。設置POST HTTP請求創建變量.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文件。
感謝您的答覆!我能夠使用您發送的內容並使其工作。我只是添加了你發送給我的視圖並使按鈕下載了該文件。我將探索如何下載並立即打開文件。再次感謝! – user2716271