回答編集履歴
1
追加
test
CHANGED
@@ -27,3 +27,51 @@
|
|
27
27
|
})
|
28
28
|
|
29
29
|
```
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
----
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
モデルにauto incrementalなprimary keyがあるなら、それがidにマッピングされています。
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
[https://docs.djangoproject.com/ja/2.0/intro/tutorial02/#activating-models](https://docs.djangoproject.com/ja/2.0/intro/tutorial02/#activating-models)
|
42
|
+
|
43
|
+
に
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
> あなたが使用しているデータベースに合わせて、auto_increment (MySQL)、 serial (PostgreSQL) もしくは integer primary key autoincrement (SQLite) のようなデータベースに特化した型が自動的に選択され生成されます。フィールド名のクォーティング (例えば、ダブルクォートにするか、シングルクォートにするか) も同様です。
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
とあってこれを読んでいるはずです。
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
そして、
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
[https://docs.djangoproject.com/ja/2.0/intro/tutorial02/#playing-with-the-api](https://docs.djangoproject.com/ja/2.0/intro/tutorial02/#playing-with-the-api)
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
ここで、Questionクラスの定義にid属性がないにも関わらず`q.id`が引けていることも、`q.choice_set.all()`でChoiceのリストを取り出せることを**確認しているはず**です。
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
Choiceもauto incrementalなprimary keyを持ってますから。`id`があります。
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
----
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
[https://docs.djangoproject.com/en/2.0/ref/models/instances/#auto-incrementing-primary-keys](https://docs.djangoproject.com/en/2.0/ref/models/instances/#auto-incrementing-primary-keys)
|
76
|
+
|
77
|
+
このあたりですね。
|