安装程序包含Django和Materialize视图库。你知道吗
两个问题:
1)使用Materialize复选框时,如何将参数从html传输到.py文件?你知道吗
2)如果这样做有效,那么如何将它们保留在会话中,以便下次访问页面时,复选框不为空?你知道吗
我在google上搜索了很多次,做了很多尝试都没有成功。你知道吗
库:href=“https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css““
你知道吗主页.html地址:
<form action="#">
{% for sites in wsites %}
<label >
<input type="checkbox" name="option{{sites.id}}" id="option{{sites.id}}" value={{sites.id}}/>
<span>{{sites.name}} </span>
</label>
<br>
{% endfor %}
</form>
你知道吗视图.py你知道吗
def homepage(request):
if request.method == 'POST':
print(request.POST)
return render(request = request,
template_name='main/home.html',
context = {"wsites":Sites.objects.all })
会话参数为空列表,即打印(请求.POST) = []. 如果能得到一些帮助来解决这个问题,我将不胜感激。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐