質問編集履歴
3
情報の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,41 +1,3 @@
|
|
1
1
|
Djangoにおいてクラスベース汎用ビューのUpdateViewを関数ビューに書き換えたいです。
|
2
2
|
|
3
3
|
どのようにすれば良いでしょうか?
|
4
|
-
|
5
|
-
```python
|
6
|
-
|
7
|
-
class PostUpdateView(UpdateView):
|
8
|
-
|
9
|
-
model = Post
|
10
|
-
|
11
|
-
form_class = PostForm
|
12
|
-
|
13
|
-
success_url = reverse_lazy('post:update_done')
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
def update_done(request):
|
18
|
-
|
19
|
-
return render(request, 'post/update_done.html')
|
20
|
-
|
21
|
-
```
|
22
|
-
|
23
|
-
わかる方が居ましたらアドバイスお願いします。
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
model.py
|
28
|
-
|
29
|
-
```python
|
30
|
-
|
31
|
-
class Post(models.Model):
|
32
|
-
|
33
|
-
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
34
|
-
|
35
|
-
date = models.DateField(verbose_name="日付",default=datetime.now)
|
36
|
-
|
37
|
-
post = models.TextField(verbose_name="投稿")
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
```
|
2
情報の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
```python
|
6
6
|
|
7
|
-
class
|
7
|
+
class PostUpdateView(UpdateView):
|
8
8
|
|
9
9
|
model = Post
|
10
10
|
|
1
情報追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -21,3 +21,21 @@
|
|
21
21
|
```
|
22
22
|
|
23
23
|
わかる方が居ましたらアドバイスお願いします。
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
model.py
|
28
|
+
|
29
|
+
```python
|
30
|
+
|
31
|
+
class Post(models.Model):
|
32
|
+
|
33
|
+
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
34
|
+
|
35
|
+
date = models.DateField(verbose_name="日付",default=datetime.now)
|
36
|
+
|
37
|
+
post = models.TextField(verbose_name="投稿")
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
```
|