質問編集履歴
3
changed code
title
CHANGED
File without changes
|
body
CHANGED
@@ -10,40 +10,29 @@
|
|
10
10
|
post = Post.objects.get(pk=pk)
|
11
11
|
if request.method == 'POST':
|
12
12
|
form = CommentForm(request.POST, request.FILES)
|
13
|
-
|
14
|
-
comment=form.save(commit=False)
|
15
|
-
comment.post=post
|
16
13
|
|
17
|
-
if
|
14
|
+
if form.is_valid():
|
18
|
-
|
15
|
+
comment=form.save(commit=False)
|
19
|
-
|
16
|
+
comment.post=post
|
20
|
-
image=request.FILES['image']
|
21
|
-
result = cloudinary.uploader.upload(image)
|
22
|
-
image_url = result['url']
|
23
|
-
form.cleaned_data['image'] = image_url
|
24
17
|
|
18
|
+
if 'image' in request.FILES:
|
19
|
+
image=request.FILES['image']
|
20
|
+
result = cloudinary.uploader.upload(image)
|
21
|
+
image_url = result['url']
|
22
|
+
form.cleaned_data['image'] = image_url
|
25
23
|
|
26
|
-
|
24
|
+
if 'video' in request.FILES:
|
27
|
-
# form = CommentForm(request.POST, request.FILES)
|
28
|
-
|
25
|
+
video = request.FILES['video']
|
29
|
-
|
26
|
+
result = cloudinary.uploader.upload_large(video)
|
30
|
-
|
27
|
+
video_url = result['url']
|
31
|
-
|
28
|
+
form.cleaned_data['video'] = video_url
|
32
|
-
|
33
|
-
|
34
|
-
if form.is_valid():
|
35
|
-
print('comment.save()')
|
36
|
-
# comment.save()
|
37
|
-
|
38
29
|
form.save()
|
39
|
-
|
40
30
|
else:
|
41
31
|
form = CommentForm()
|
42
32
|
|
43
33
|
return render(request, "registration/post_detail.html",{"post":post, "form":form})
|
44
34
|
|
45
35
|
|
46
|
-
|
47
36
|
```
|
48
37
|

|
49
38
|
|
2
gaz
title
CHANGED
File without changes
|
body
CHANGED
@@ -45,6 +45,6 @@
|
|
45
45
|
|
46
46
|
|
47
47
|
```
|
48
|
+

|
48
49
|
|
49
|
-
|
50
50
|

|
1
画像の変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -46,5 +46,5 @@
|
|
46
46
|
|
47
47
|
```
|
48
48
|
|
49
|
-
|
49
|
+
|
50
50
|

|