回答編集履歴
4
修正
test
CHANGED
@@ -26,7 +26,7 @@
|
|
26
26
|
|
27
27
|
if request.method == "POST":
|
28
28
|
|
29
|
-
form = ThreadForm(request.POST)
|
29
|
+
form = ThreadForm(request.POST)
|
30
30
|
|
31
31
|
if form.is_valid():
|
32
32
|
|
3
修正
test
CHANGED
@@ -30,8 +30,6 @@
|
|
30
30
|
|
31
31
|
if form.is_valid():
|
32
32
|
|
33
|
-
form = ThreadForm()
|
34
|
-
|
35
33
|
thread = form.save(commit=False)
|
36
34
|
|
37
35
|
thread.user = request.user
|
2
追記
test
CHANGED
@@ -26,6 +26,8 @@
|
|
26
26
|
|
27
27
|
if request.method == "POST":
|
28
28
|
|
29
|
+
form = ThreadForm(request.POST)
|
30
|
+
|
29
31
|
if form.is_valid():
|
30
32
|
|
31
33
|
form = ThreadForm()
|
@@ -38,6 +40,8 @@
|
|
38
40
|
|
39
41
|
messages.success(request, "投稿が完了しました!")
|
40
42
|
|
43
|
+
form = ThreadForm()
|
44
|
+
|
41
45
|
else:
|
42
46
|
|
43
47
|
form = ThreadForm()
|
1
修正
test
CHANGED
@@ -15,3 +15,33 @@
|
|
15
15
|
form = ~~Form()
|
16
16
|
|
17
17
|
```にすれば、送った時書いていたものが消えます。
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
---追記---
|
22
|
+
|
23
|
+
```Python
|
24
|
+
|
25
|
+
def create_thread(request):
|
26
|
+
|
27
|
+
if request.method == "POST":
|
28
|
+
|
29
|
+
if form.is_valid():
|
30
|
+
|
31
|
+
form = ThreadForm()
|
32
|
+
|
33
|
+
thread = form.save(commit=False)
|
34
|
+
|
35
|
+
thread.user = request.user
|
36
|
+
|
37
|
+
thread.save()
|
38
|
+
|
39
|
+
messages.success(request, "投稿が完了しました!")
|
40
|
+
|
41
|
+
else:
|
42
|
+
|
43
|
+
form = ThreadForm()
|
44
|
+
|
45
|
+
return redirect('app:display_threads')
|
46
|
+
|
47
|
+
```普通request.method == "POST"で分岐すると思うのですが...
|