質問編集履歴
1
views.pyを追加しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -28,6 +28,8 @@
|
|
28
28
|
ディレクトリ構造
|
29
29
|
```
|
30
30
|
|- manage.py
|
31
|
+
|- nba/ (appの名前)
|
32
|
+
| └ views.py
|
31
33
|
|- templates/
|
32
34
|
| └ .html
|
33
35
|
|- templatetags/
|
@@ -64,7 +66,7 @@
|
|
64
66
|
|
65
67
|
```
|
66
68
|
|
67
|
-
- .html(templatesの中)
|
69
|
+
- stats.html(templatesの中)
|
68
70
|
|
69
71
|
{% hoge %}はあとから追加
|
70
72
|
```html
|
@@ -127,8 +129,31 @@
|
|
127
129
|
|
128
130
|
```
|
129
131
|
|
132
|
+
- views.py
|
133
|
+
```python
|
134
|
+
from django.shortcuts import render
|
135
|
+
from django.views.generic import ListView,TemplateView
|
136
|
+
from .models import PlayerModel
|
137
|
+
from django.urls import reverse_lazy
|
130
138
|
|
139
|
+
# Create your views here
|
131
140
|
|
141
|
+
class PlayerList(ListView):
|
142
|
+
template_name = "list.html"
|
143
|
+
model = PlayerModel
|
144
|
+
|
145
|
+
class ShowStats(TemplateView):
|
146
|
+
template_name = "stats.html"
|
147
|
+
model = PlayerModel
|
148
|
+
|
149
|
+
def get_context_data(self, **kwargs):
|
150
|
+
context = super().get_context_data(**kwargs)
|
151
|
+
context['object'] = PlayerModel.objects.get(pk=self.kwargs.get('pk'))
|
152
|
+
return context
|
153
|
+
```
|
154
|
+
|
155
|
+
|
156
|
+
|
132
157
|
###発生している問題・エラーメッセージ
|
133
158
|
No module named(手順4)
|
134
159
|
```
|