私のホームページにはラジオボタンが含まれているので、別のアプリケーションに移動したりメッセージを表示することができます。チェックしたボタンのテストが正しく書かれていないと思います。 ログ/ views.pyviews.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 %}
禁止されています(CSRFトークンがないか間違っています):/ log/and home .htmlスーパーユーザーが最初に家にアクセスする必要があるため、削除できません。 – user5996908
'django.middleware.csrf.CsrfViewMiddleware 'あなたの' settings.py'ファイルの 'MIDDLEWARE_CLASSES'から – ahmed
ありがとうございます。しかし、削除してもうまくいきません。 – user5996908