Browse Source

post

master
jfinn 6 days ago
parent
commit
f112ddb9f2
3 changed files with 23 additions and 0 deletions
  1. 1
    0
      djc_srv/urls.py
  2. 9
    0
      wsps/models.py
  3. 13
    0
      wsps/views.py

+ 1
- 0
djc_srv/urls.py View File

25
     path('jstp_dev0', wsps.views.fn_v0),
25
     path('jstp_dev0', wsps.views.fn_v0),
26
     path('jstp_dev1/', wsps.views.fn_v1),
26
     path('jstp_dev1/', wsps.views.fn_v1),
27
     path('jstp_dev2/', wsps.views.fn_v2),
27
     path('jstp_dev2/', wsps.views.fn_v2),
28
+    path('jstp_dev3', wsps.views.CreatePostView),
28
 ]
29
 ]
29
 
30
 
30
 
31
 

+ 9
- 0
wsps/models.py View File

1
 from django.db import models
1
 from django.db import models
2
 
2
 
3
 # Create your models here.
3
 # Create your models here.
4
+# class Document(models.Model):
5
+	# docfile = models.FileField(upload_to='documents/%Y/%m/%d')
6
+
7
+class Post(models.Model):
8
+    title = models.TextField()
9
+    cover = models.ImageField(upload_to='images/')
10
+
11
+    def __str__(self):
12
+        return self.title

+ 13
- 0
wsps/views.py View File

8
 
8
 
9
 from django.views.decorators.csrf import csrf_exempt
9
 from django.views.decorators.csrf import csrf_exempt
10
 
10
 
11
+from django.views.generic import ListView, CreateView  # new
12
+
13
+
11
 # from wsps.tasks_loop import *
14
 # from wsps.tasks_loop import *
12
 
15
 
13
 # wsps.
16
 # wsps.
52
 def fn_v0(request,*a,**kw):
55
 def fn_v0(request,*a,**kw):
53
 	return HttpResponse("fn_v0") 
56
 	return HttpResponse("fn_v0") 
54
 
57
 
58
+
59
+
60
+class CreatePostView(CreateView):  # new
61
+	model = Post
62
+	form_class = PostForm
63
+	template_name = "post.html"
64
+	# success_url = reverse_lazy("home")
65
+
66
+
67
+
55
 arbitrary_string_as_template = "abc 123 {% csrf_token %}"
68
 arbitrary_string_as_template = "abc 123 {% csrf_token %}"
56
 def fn_v1(request,*a,**kw):
69
 def fn_v1(request,*a,**kw):
57
 
70
 

Loading…
Cancel
Save