質問編集履歴

2

polls/admin.pyを編集した。

2019/07/22 05:08

投稿

ingramzero
ingramzero

スコア16

test CHANGED
File without changes
test CHANGED
@@ -186,74 +186,36 @@
186
186
 
187
187
  ```ここに言語を入力
188
188
 
189
+ from django.contrib import admin
190
+
189
- import datetime
191
+ from .models import Question
192
+
193
+
194
+
190
-
195
+ admin.site.register(Question)
196
+
191
-
197
+ # Register your models here.
198
+
199
+
200
+
201
+ ```
202
+
203
+ **todo/models.py**
204
+
205
+ ---
206
+
207
+ ```ここに言語を入力
192
208
 
193
209
  from django.db import models
194
210
 
195
- from django.utils import timezone
211
+
196
-
197
-
198
-
199
-
200
-
212
+
201
- class Question(models.Model):
213
+ class Post(models.Model):
202
-
214
+
203
- question_text = models.CharField(max_length=200)#質問文
215
+ body = models.CharField(max_length=200)
204
-
205
- pub_date = models.DateTimeField('date published')#公開日
206
-
207
-
208
-
209
- def __str__(self):
210
-
211
- return self.question_text
212
-
213
-
214
-
215
- def was_published_recently(self):
216
-
217
- return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
218
-
219
-
220
-
221
- class Choice:
222
-
223
- question = models.ForeignKey(Question, on_delete=models.CASCADE)#質問文の読み込み
224
-
225
- choice_text = models.CharField(max_length=200)#質問に対する選択肢
226
-
227
- votes = models.IntegerField(default=0)#投票数
228
-
229
-
230
-
231
- def __str__(self):
232
-
233
- return self.choice_text
234
216
 
235
217
  # Create your models here.
236
218
 
237
-
238
-
239
- ```
240
-
241
- **todo/models.py**
242
-
243
- ---
244
-
245
- ```ここに言語を入力
246
-
247
- from django.db import models
248
-
249
-
250
-
251
- class Post(models.Model):
252
-
253
- body = models.CharField(max_length=200)
254
-
255
- # Create your models here.
256
-
257
219
  ```
258
220
 
259
221
  **todo/admin.py**

1

リンクをたどれるように変更しました。

2019/07/22 05:08

投稿

ingramzero
ingramzero

スコア16

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,4 @@
1
- https://qiita.com/minnsou/items/db69ab931207ffec66eeを参考にしてdjangoのAPIを叩くところまで進んだのですが、q.choice_set.all()というコマンドを叩いたら↓↓というエラーが吐かれました。どうかご助力お願い出来ますでしょうか。
1
+ [Djangoまとめ](https://qiita.com/minnsou/items/db69ab931207ffec66ee)を参考にしてdjangoのAPIを叩くところまで進んだのですが、q.choice_set.all()というコマンドを叩いたら↓↓というエラーが吐かれました。どうかご助力お願い出来ますでしょうか。
2
2
 
3
3
  ```
4
4