1
+ {
2
+ "Django View" : {
3
+ "scope" : " python" ,
4
+ "prefix" : [
5
+ " django-view"
6
+ ],
7
+ "body" : [
8
+ " class $1(View):" ,
9
+ " \t def get(self, request: HttpRequest):" ,
10
+ " \t\t $2" ,
11
+ " " ,
12
+ " \t def post(self, request: HttpRequest):" ,
13
+ " \t\t $3"
14
+ ],
15
+ "description" : " Class based view for django"
16
+ },
17
+ "Django Template View" : {
18
+ "scope" : " python" ,
19
+ "prefix" : [
20
+ " django-template-view"
21
+ ],
22
+ "body" : [
23
+ " class $1(TemplateView):" ,
24
+ " \t template_name = $2" ,
25
+ " " ,
26
+ " \t def post(self, request: HttpRequest):" ,
27
+ " \t\t $3"
28
+ ]
29
+ },
30
+ "Django Auth View" : {
31
+ "scope" : " python" ,
32
+ "prefix" : [
33
+ " django-auth-view"
34
+ ],
35
+ "body" : [
36
+ " class $1(LoginRequiredMixin, View):" ,
37
+ " \t template_name: str = \" $2\" " ,
38
+ " \t login_url = ${3|reverse,reverse_lazy|}(\" $4\" )"
39
+ ]
40
+ },
41
+ "Django Urls Template" : {
42
+ "scope" : " python" ,
43
+ "prefix" : [
44
+ " django-urls"
45
+ ],
46
+ "body" : [
47
+ " from django.urls import path" ,
48
+ " from . import views" ,
49
+ " " ,
50
+ " app_name = \" $1\" " ,
51
+ " urlpatterns = [" ,
52
+ " \t $2" ,
53
+ " ]"
54
+ ]
55
+ },
56
+ "Django Url Path" : {
57
+ "scope" : " python" ,
58
+ "prefix" : [
59
+ " django-url-path"
60
+ ],
61
+ "body" : [
62
+ " path(\" $1\" , views.$2, name=\" $3\" ),"
63
+ ],
64
+ "description" : " Django path in urls.py"
65
+ },
66
+ "Django Model" : {
67
+ "scope" : " python" ,
68
+ "prefix" : [
69
+ " django-model"
70
+ ],
71
+ "body" : [
72
+ " class $1(model.Model):" ,
73
+ " \t $2" ,
74
+ " " ,
75
+ " \t def __str__(self):" ,
76
+ " \t\t # view of the model in admin pannel" ,
77
+ " \t\t return $3" ,
78
+ " " ,
79
+ " \t def save(self, *args, **kwargs):" ,
80
+ " \t\t # logic before you save you model object" ,
81
+ " \t\t $4" ,
82
+ " \t\t super().save(*args, **kwargs)" ,
83
+ " " ,
84
+ " \t class Meta:" ,
85
+ " \t\t # for naming you table" ,
86
+ " \t\t db_table = \" $5\" "
87
+ ]
88
+ },
89
+ "Django Base Template" : {
90
+ "scope" : " django-html,django-txt,html" ,
91
+ "prefix" : [
92
+ " django-temp" ,
93
+ " django-base"
94
+ ],
95
+ "body" : [
96
+ " {% load static %}" ,
97
+ " <!DOCTYPE html>" ,
98
+ " <html lang=\" en\" >" ,
99
+ " <head>" ,
100
+ " \t <meta charset=\" UTF-8\" />" ,
101
+ " \t <meta http-equiv=\" X-UA-Compatible\" content=\" IE=edge\" />" ,
102
+ " \t <meta name=\" viewport\" content=\" width=device-width, initial-scale=1.0\" />" ,
103
+ " \t <title>$1</title>" ,
104
+ " \t {% block headScripts%}{% endblock headScripts %}" ,
105
+ " \t <link rel=\" shortcut icon\" href=\" {% static 'svg/logo.svg' %}\" type=\" image/x-icon\" >" ,
106
+ " \t {% comment %} update css_version upon changes in css files {% endcomment %}" ,
107
+ " \t {% with css_version=\" 2.1\" %}" ,
108
+ " \t\t {% block stylesheet %}{% endblock stylesheet%}" ,
109
+ " \t {% endwith %}" ,
110
+ " </head>" ,
111
+ " <body>" ,
112
+ " \t {% block body %}{% endblock body %}" ,
113
+ " \t {% comment %} update js_version upon changes in js files {% endcomment %}" ,
114
+ " \t {% with js_version=\" 2.1\" %}" ,
115
+ " \t\t {% block scripts %}{% endblock scripts %}" ,
116
+ " \t {% endwith %}" ,
117
+ " </body>" ,
118
+ " </html>"
119
+ ]
120
+ },
121
+ "Django Page Template" : {
122
+ "scope" : " django-html,django-txt,html" ,
123
+ "prefix" : [
124
+ " django-page" ,
125
+ " django-html"
126
+ ],
127
+ "body" : [
128
+ " {% extends 'head.djt' %}" ,
129
+ " {% comment %} Template inherits from head.djt {% endcomment %}" ,
130
+ " {% load static %}" ,
131
+ " " ,
132
+ " {% block stylesheet %}" ,
133
+ " \t <link rel=\" stylesheet\" type=\" text/css\" href=\" {% static '$1' %}?version={{css_version}}\" >" ,
134
+ " {% endblock stylesheet%}" ,
135
+ " " ,
136
+ " {% block body %}" ,
137
+ " {% endblock body %}" ,
138
+ " " ,
139
+ " {% block scripts %}" ,
140
+ " \t <script src=\" {% static '$2'%}?version={{ js_version }}\" type=\" module\" ></script>" ,
141
+ " {% endblock scripts %}"
142
+ ]
143
+ }
144
+ }
0 commit comments