【发布时间】:2016-04-15 17:06:20
【问题描述】:
我有一个 django 项目,其中我的主页包含单选按钮,这使我有机会转到另一个应用程序或显示消息。我认为我对检查按钮的测试没有正确编写。 日志/views.py
from django.shortcuts import render
from django.contrib.auth.decorators import login_required,user_passes_test
from aps import views
from django.http import HttpResponse
@login_required()
def home(request):
if request.user.is_superuser:
return render(request,"home.html")
if ('choix1').checked in request.POST:
return HttpResponse("hedha lmail")
elif 'choix2' in request.POST:
return HttpResponse("hedha ltemps")
elif 'choix3' in request.POST:
return views.index(request)
else :
return HttpResponse("You have not chosenn ay choice")
else:
return views.index(request)
home.html
{% extends 'base.html' %}
{% block content %}
<div class="container">
<div class="row">
<div class="jumbotron">
<h1>Hello</h1>
<p>You are on your account</p>
</div>
<div class="jumbotron">
<FORM>
<p>you have the opprtunity to : </P>
<INPUT type= "radio" name="choix1" id="choix1" value="mail"> change mail sender
<INPUT type= "radio" name="choix2" id="choix2" value="temps"> change frequency of getting temperqture sensor's value
<INPUT type= "radio" name="choix3" id="choix3" value="graph"> show graph <br>
<INPUT type= "submit" value="ok">
</FORM>
</div>
</div>
</div>
{% endblock %}
【问题讨论】: