質問編集履歴
3
ビューの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -56,6 +56,62 @@
|
|
56
56
|
|
57
57
|
|
58
58
|
|
59
|
+
*accounts/views.py
|
60
|
+
|
61
|
+
```Python
|
62
|
+
|
63
|
+
from django.contrib.auth.views import LoginView as AuthLoginView
|
64
|
+
|
65
|
+
from django.shortcuts import render, redirect
|
66
|
+
|
67
|
+
from django.urls import reverse
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
from .forms import LoginForm
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
class LoginView(AuthLoginView):
|
78
|
+
|
79
|
+
def post(self, request, *args, **kwargs):
|
80
|
+
|
81
|
+
form = LoginForm(request.POST)
|
82
|
+
|
83
|
+
is_valid = form.is_valid()
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
if not is_valid:
|
88
|
+
|
89
|
+
return render(request, 'accounts/login.html', {'form': form})
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
return redirect(reverse('shop:book_list'))
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
def get(self, request, *args, **kwargs):
|
98
|
+
|
99
|
+
form = LoginForm()
|
100
|
+
|
101
|
+
return render(request, 'accounts/login.html', {'form': form})
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
# accounts/urls.py でURLディスパッチャされてくる
|
108
|
+
|
109
|
+
login = LoginView.as_view()
|
110
|
+
|
111
|
+
```
|
112
|
+
|
113
|
+
|
114
|
+
|
59
115
|
*accounts/forms.py
|
60
116
|
|
61
117
|
```Python
|
2
エラーがあるかどうかの判定文を修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -28,7 +28,7 @@
|
|
28
28
|
|
29
29
|
```python
|
30
30
|
|
31
|
-
if self.errors
|
31
|
+
if self.errors:
|
32
32
|
|
33
33
|
return
|
34
34
|
|
1
不要な見出しの削除
test
CHANGED
File without changes
|
test
CHANGED
@@ -201,19 +201,3 @@
|
|
201
201
|
Server time: Fri, 12 Oct 2018 01:15:23 +0000
|
202
202
|
|
203
203
|
```
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
### 試したこと
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
ここに問題に対して試したことを記載してください。
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
### 補足情報(FW/ツールのバージョンなど)
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
ここにより詳細な情報を記載してください。
|