... html") を更新して、HTML の <form> 要素を入れましょう。 polls/templates/polls/detail.html ¶ < form action = " {% url 'polls:vote' question.id %} " method = "post" > {% csrf_token %} < fieldset > < legend >< h1 > {{ question.question_text }} </ h1 ></ ... loop .counter }} " > {{ choice.choice_text }} </ label >< br > {% endfor %} </ fieldset > < input type = "submit" value = "Vote" > </ form > 簡単に説明: 上のテンプレートは、各質問の選択肢のラジオボタンを表示するものです。各ラジオボタンの value は、関 ... hoice=# (#は選んだ選択肢のID)が送信されます。これは、HTMLフォームの基本的な概念です。 フォームの action を {% url 'polls:vote' question.id %} に設定し、 method="post" を指定しています。 ( method="get" ではなく) method="post" を使用することは非常に重 ... ... html") を更新して、HTML の <form> 要素を入れましょう。 polls/templates/polls/detail.html ¶ < form action = " {% url 'polls:vote' question.id %} " method = "post" > {% csrf_token %} < fieldset > < legend >< h1 > {{ question.question_text }} </ h1 ></ ... loop .counter }} " > {{ choice.choice_text }} </ label >< br > {% endfor %} </ fieldset > < input type = "submit" value = "Vote" > </ form > 簡単に説明: 上のテンプレートは、各質問の選択肢のラジオボタンを表示するものです。各ラジオボタンの value は、関 ... hoice=# (#は選んだ選択肢のID)が送信されます。これは、HTMLフォームの基本的な概念です。 フォームの action を {% url 'polls:vote' question.id %} に設定し、 method="post" を指定しています。 ( method="get" ではなく) method="post" を使用することは非常に重 ... ... stion_id ): response = "You're looking at the results of question %s ." return HttpResponse ( response % question_id ) def vote ( request , question_id ): return HttpResponse ( "You're voting on question %s ." % question_id ) 次の path() コールを追加 ... ail" ), # ex: /polls/5/results/ path ( "<int:question_id>/results/" , views . results , name = "results" ), # ex: /polls/5/vote/ path ( "<int:question_id>/vote/" , views . vote , name = "vote" ), ] ブラウザで "/polls/34/" を見てください。 detail() 関 ... 数が実行され、URLで指定したIDが表示されます。 "/polls/34/results/" と "/polls/34/vote/" も試してみてください--これらはプレースホルダの結果と投票ページを表示します。 誰かがWebサイトの 「/polls/34/」 をリクエス ... ... stion_id ): response = "You're looking at the results of question %s ." return HttpResponse ( response % question_id ) def vote ( request , question_id ): return HttpResponse ( "You're voting on question %s ." % question_id ) 次の path() コールを追加 ... ail" ), # ex: /polls/5/results/ path ( "<int:question_id>/results/" , views . results , name = "results" ), # ex: /polls/5/vote/ path ( "<int:question_id>/vote/" , views . vote , name = "vote" ), ] ブラウザで "/polls/34/" を見てください。 detail() 関 ... 数が実行され、URLで指定したIDが表示されます。 "/polls/34/results/" と "/polls/34/vote/" も試してみてください--これらはプレースホルダの結果と投票ページを表示します。 誰かがWebサイトの 「/polls/34/」 をリクエス ... ... の属性ルックアップを真偽値として評価することは User.has_perm() の代替となります。たとえば、ログインしているユーザが foo.add_vote というパーミッションを持っているかどうかを調べるには、次のようにします: {% if perms.foo.add_vote %} 以下は、テンプレートで ... 、より完全な例です: {% if perms.foo %} < p > You have permission to do something in the foo app. </ p > {% if perms.foo.add_vote %} < p > You can vote! </ p > {% endif %} {% if perms.foo.add_driving %} < p > You can drive! </ p > {% endif %} {% else % ... in %} ステートメントを使ってパーミッションをルックアップすることも可能です。例えば: {% if 'foo' in perms %} {% if 'foo.add_vote' in perms %} < p > In lookup works, too. </ p > {% endif %} {% endif %} admin 内でユーザを管理する ¶ django.contrib.admin ... ... の属性ルックアップを真偽値として評価することは User.has_perm() の代替となります。たとえば、ログインしているユーザが foo.add_vote というパーミッションを持っているかどうかを調べるには、次のようにします: {% if perms.foo.add_vote %} 以下は、テンプレートで ... 、より完全な例です: {% if perms.foo %} < p > You have permission to do something in the foo app. </ p > {% if perms.foo.add_vote %} < p > You can vote! </ p > {% endif %} {% if perms.foo.add_driving %} < p > You can drive! </ p > {% endif %} {% else % ... in %} ステートメントを使ってパーミッションをルックアップすることも可能です。例えば: {% if 'foo' in perms %} {% if 'foo.add_vote' in perms %} < p > In lookup works, too. </ p > {% endif %} {% endif %} admin 内でユーザを管理する ¶ django.contrib.admin ... ... of candidates to the Django Forum , and the election begins. The DSF Board provides a voting form accessible to registered voters, and is the custodian of the votes. 投票は、候補者名簿と候補者に関する関連資料を無作為に並べた無記名投票によって行われま ... 記載された候補者5名まで投票することができます。 The election conclude one week after it begins. The DSF Board then tally the votes and produce a summary, including the total number of votes cast and the number received by each candidate. This summary i ... s ratified by a majority vote of the DSF Board, then posted by the Secretary of the DSF to the Django Forum . The five candidates with the highest vote ... ... th.decorators import login_required , permission_required from django.views.generic import TemplateView from .views import VoteView urlpatterns = [ path ( "about/" , login_required ( TemplateView . as_view ( template_name = "secret.html" ))), path ( ... "vote/" , permission_required ( "polls.can_vote" )( VoteView . as_view ())), ] このアプローチではデコレータはインスタンスごとに適 ... ... of candidates to the Django Forum , and the election begins. The DSF Board provides a voting form accessible to registered voters, and is the custodian of the votes. 投票は、候補者名簿と候補者に関する関連資料を無作為に並べた無記名投票によって行われま ... 記載された候補者5名まで投票することができます。 The election conclude one week after it begins. The DSF Board then tally the votes and produce a summary, including the total number of votes cast and the number received by each candidate. This summary i ... s ratified by a majority vote of the DSF Board, then posted by the Secretary of the DSF to the Django Forum . The five candidates with the highest vote ... ... th.decorators import login_required , permission_required from django.views.generic import TemplateView from .views import VoteView urlpatterns = [ path ( "about/" , login_required ( TemplateView . as_view ( template_name = "secret.html" ))), path ( ... "vote/" , permission_required ( "polls.can_vote" )( VoteView . as_view ())), ] このアプローチではデコレータはインスタンスごとに適 ... 2026年10月08日