... l.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/」 をリクエス ... ... の属性ルックアップを真偽値として評価することは 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 ())), ] このアプローチではデコレータはインスタンスごとに適 ... ... Permission オブジェクトには以下のフィールドがあります: class models. Permission name 必須です。255 文字以下です。例: 'Can vote' 。 content_type 必須です。 ContentType モデルを参照する外部キーです。 codename 必須です。100 文字以下です。例: 'can_vote' ... ... e reverter-to-be then try to work it out on the Django Forum . If an agreement can't be reached then it should be put to a vote. もしそのコミットが、確認され、公開されたセキュリティ脆弱性を含んでいた場合、そのコミットは誰の許可も得ずに即座に差し戻され ... ... all of them, but anyone in the Django community can participate in any role except merger. The merger role is granted by a vote of the Steering Council . Triagers: anyone can take on this role by checking whether a ticket describes a real issue and k ... ... は、 Question と Choice の2つのモデルを作成します。 Question には質問文と公開日時があります。 Choice には選択肢のテキストと vote という2つのフィールドがあります。各 Choice は1つの Question に関連づけられています。 Django では、こうした概念を簡単な Pyt ... on = models . ForeignKey ( Question , on_delete = models . CASCADE ) choice_text = models . CharField ( max_length = 200 ) votes = models . IntegerField ( default = 0 ) コードは単純明解ですね。各モデルは一つのクラスで表現され、いずれも django.db.mode ... ーススキーマで使われる他、後で述べるバリデーションでも使われます。 Field はいくつかオプションの引数も取れます。今回の場合、 votes の default 値を 0 に設定しました。 最後に、 ForeignKey を使用してリレーションシップが定義されていることに注目してください ... 2026年10月08日