質問編集履歴

2

コードの変更

2018/11/29 06:36

投稿

sr2460
sr2460

スコア50

test CHANGED
File without changes
test CHANGED
@@ -186,44 +186,6 @@
186
186
 
187
187
 
188
188
 
189
-
190
-
191
- ```
192
-
193
- def vote(request, question_id):
194
-
195
- question = get_object_or_404(Question, pk=question_id)
196
-
197
- try:
198
-
199
- selected_choice = question.choice_set.get(pk=request.POST['choice'])
200
-
201
- **choice_comment = question.comment.get(pk=request.POST['choice'])**←追加
202
-
203
- except (KeyError, Choice.DoesNotExist):
204
-
205
- return render(request, 'polls/detail.html', {
206
-
207
- 'question': question,
208
-
209
- 'error_message': "投票内容を選んでください",
210
-
211
- })
212
-
213
- else:
214
-
215
- selected_choice.votes += 1
216
-
217
- selected_choice.save()
218
-
219
- **choice_comment.save()**←追加
220
-
221
- return HttpResponseRedirect(reverse('polls:results', args=(question.id,)))
222
-
223
- ```
224
-
225
-
226
-
227
189
  choice_comment = question.comment.get(pk=request.POST['choice'])を定義し、modelsで作成したcomment = models.TextField()を呼び出し、
228
190
 
229
191
  さらに

1

画像の追加

2018/11/29 06:36

投稿

sr2460
sr2460

スコア50

test CHANGED
File without changes
test CHANGED
@@ -116,6 +116,8 @@
116
116
 
117
117
 
118
118
 
119
+ ![イメージ説明](ea566c13584073b840d96e20f0e35eef.png)
120
+
119
121
 
120
122
 
121
123
  modelsの変更なのでmigrationをすれば良いかと思いコマンドを入力しましたが、