1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
|
priority -50
# This files will define django snippets from sublime text djaneiro
# FORMS SNIPPETS
snippet form "Form" b
class ${1:FORMNAME}(forms.Form):
${2:# TODO: Define form fields here}
endsnippet
snippet modelform "ModelForm" b
class ${1:MODELNAME}Form(forms.ModelForm):
class Meta:
model = $1
endsnippet
snippet fbool "BooleanField" b
${1:FIELDNAME} = forms.BooleanField($2)
endsnippet
snippet fchar "CharField" b
${1:FIELDNAME} = forms.CharField($2)
endsnippet
snippet fchoice "ChoiceField" b
${1:FIELDNAME} = forms.ChoiceField($2)
endsnippet
snippet fcombo "ComboField" b
${1:FIELDNAME} = forms.ComboField($2)
endsnippet
snippet fdate "DateField" b
${1:FIELDNAME} = forms.DateField($2)
endsnippet
snippet fdatetime "DateTimeField" b
${1:FIELDNAME} = forms.DateTimeField($2)
endsnippet
snippet fdecimal "DecimalField" b
${1:FIELDNAME} = forms.DecimalField($2)
endsnippet
snippet fmail "EmailField" b
${1:FIELDNAME} = forms.EmailField($2)
endsnippet
snippet ffile "FileField" b
${1:FIELDNAME} = forms.FileField($2)
endsnippet
snippet ffilepath "FilePathField" b
${1:FIELDNAME} = forms.FilePathField($2)
endsnippet
snippet ffloat "FloatField" b
${1:FIELDNAME} = forms.FloatField($2)
endsnippet
snippet fip "IPAddressField" b
${1:FIELDNAME} = forms.IPAddressField($2)
endsnippet
snippet fimg "ImageField" b
${1:FIELDNAME} = forms.ImageField($2)
endsnippet
snippet fint "IntegerField" b
${1:FIELDNAME} = forms.IntegerField($2)
endsnippet
snippet fmochoice "ModelChoiceField" b
${1:FIELDNAME} = forms.ModelChoiceField($2)
endsnippet
snippet fmomuchoice "ModelMultipleChoiceField" b
${1:FIELDNAME} = forms.ModelMultipleChoiceField($2)
endsnippet
snippet fmuval "MultiValueField" b
${1:FIELDNAME} = forms.MultiValueField($2)
endsnippet
snippet fmuchoice "MultipleChoiceField" b
${1:FIELDNAME} = forms.MultipleChoiceField($2)
endsnippet
snippet fnullbool "NullBooleanField" b
${1:FIELDNAME} = forms.NullBooleanField($2)
endsnippet
snippet freg "RegexField" b
${1:FIELDNAME} = forms.RegexField($2)
endsnippet
snippet fslug "SlugField" b
${1:FIELDNAME} = forms.SlugField($2)
endsnippet
snippet fsdatetime "SplitDateTimeField" b
${1:FIELDNAME} = forms.SplitDateTimeField($2)
endsnippet
snippet ftime "TimeField" b
${1:FIELDNAME} = forms.TimeField($2)
endsnippet
snippet ftchoice "TypedChoiceField" b
${1:FIELDNAME} = forms.TypedChoiceField($2)
endsnippet
snippet ftmuchoice "TypedMultipleChoiceField" b
${1:FIELDNAME} = forms.TypedMultipleChoiceField($2)
endsnippet
snippet furl "URLField" b
${1:FIELDNAME} = forms.URLField($2)
endsnippet
# MODELS SNIPPETS
snippet model "Model" b
class ${1:MODELNAME}(models.Model):
${0}
class Meta:
verbose_name = "$1"
verbose_name_plural = "$1s"
def __str__(self):
return super($1, self).__str__()
endsnippet
snippet modelfull "Model" b
class ${1:MODELNAME}(models.Model):
${2:# TODO: Define fields here}
class Meta:
verbose_name = "$1"
verbose_name_plural = "$1s"
def __str__(self):
return super($1, self).__str__()
def save(self):
return super($1, self).save()
@models.permalink
def get_absolute_url(self):
return ('')
${3:# TODO: Define custom methods here}
endsnippet
snippet mauto "AutoField" b
${1:FIELDNAME} = models.AutoField($2)
endsnippet
snippet mbigint "BigIntegerField" b
${1:FIELDNAME} = models.BigIntegerField($2)
endsnippet
snippet mbool "BooleanField" b
${1:FIELDNAME} = models.BooleanField($2)
endsnippet
snippet mchar "CharField" b
${1:FIELDNAME} = models.CharField($2, max_length=${3:50})
endsnippet
snippet mcoseint "CommaSeparatedIntegerField" b
${1:FIELDNAME} = models.CommaSeparatedIntegerField($2)
endsnippet
snippet mdate "DateField" b
${1:FIELDNAME} = models.DateField($2)
endsnippet
snippet mdatetime "DateTimeField" b
${1:FIELDNAME} = models.DateTimeField($2)
endsnippet
snippet mdecimal "DecimalField" b
${1:FIELDNAME} = models.DecimalField(max_digits=${2:10}, decimal_places=${3:2})
endsnippet
snippet memail "EmailField" b
${1:FIELDNAME} = models.EmailField($2)
endsnippet
snippet mfile "FileField" b
${1:FIELDNAME} = models.FileField($2)
endsnippet
snippet mfilepath "FilePathField" b
${1:FIELDNAME} = models.FilePathField($2)
endsnippet
snippet mfloat "FloatField" b
${1:FIELDNAME} = models.FloatField($2)
endsnippet
snippet fk "ForeignKey" b
${1:FIELDNAME} = models.ForeignKey($2)
endsnippet
snippet mip "IPAddressField" b
${1:FIELDNAME} = models.IPAddressField($2)
endsnippet
snippet mimg "ImageField" b
${1:FIELDNAME} = models.ImageField($2)
endsnippet
snippet mint "IntegerField" b
${1:FIELDNAME} = models.IntegerField($2)
endsnippet
snippet m2m "ManyToManyField" b
${1:FIELDNAME} = models.ManyToManyField($2)
endsnippet
snippet mnullbool "NullBooleanField" b
${1:FIELDNAME} = models.NullBooleanField($2)
endsnippet
snippet o2o "OneToOneField" b
${1:FIELDNAME} = models.OneToOneField($2)
endsnippet
snippet mphone "PhoneNumberField" b
${1:FIELDNAME} = models.PhoneNumberField($2)
endsnippet
snippet mposint "PositiveIntegerField" b
${1:FIELDNAME} = models.PositiveIntegerField($2)
endsnippet
snippet mpossmallint "PositiveSmallIntegerField" b
${1:FIELDNAME} = models.PositiveSmallIntegerField($2)
endsnippet
snippet mslug "SlugField" b
${1:FIELDNAME} = models.SlugField($2)
endsnippet
snippet msmallint "SmallIntegerField" b
${1:FIELDNAME} = models.SmallIntegerField($2)
endsnippet
snippet mtext "TextField" b
${1:FIELDNAME} = models.TextField($2)
endsnippet
snippet mtime "TimeField" b
${1:FIELDNAME} = models.TimeField($2)
endsnippet
snippet murl "URLField" b
${1:FIELDNAME} = models.URLField($2)
endsnippet
snippet musstate "USStateField" b
${1:FIELDNAME} = models.USStateField($2)
endsnippet
snippet mxml "XMLField" b
${1:FIELDNAME} = models.XMLField($2)
endsnippet
# VIEWS SNIPPETS
snippet adminview "Model Admin View" b
class ${1}Admin(admin.ModelAdmin):
'''
Admin View for ${1}
'''
list_display = ('${2}',)
list_filter = ('${3}',)
inlines = [
${4}Inline,
]
raw_id_fields = ('${5}',)
readonly_fields = ('${6}',)
search_fields = ['${7}']
admin.site.register(${1}, ${1}Admin)
endsnippet
snippet createview "Generic Create View" b
class ${1:MODEL_NAME}CreateView(CreateView):
model = ${1:MODEL_NAME}
template_name = "${2:TEMPLATE_NAME}"
endsnippet
snippet deleteview "Generic Delete View" b
class ${1:MODEL_NAME}DeleteView(DeleteView):
model = ${1:MODEL_NAME}
template_name = "${2:TEMPLATE_NAME}"
endsnippet
snippet detailview "Generic Detail View" b
class ${1:MODEL_NAME}DetailView(DetailView):
model = ${1:MODEL_NAME}
template_name = "${2:TEMPLATE_NAME}"
endsnippet
snippet listview "Generic List View" b
class ${1:MODEL_NAME}ListView(ListView):
model = ${1:MODEL_NAME}
template_name = "${2:TEMPLATE_NAME}"
endsnippet
snippet stackedinline "Stacked Inline" b
class ${1}Inline(admin.StackedInline):
'''
Stacked Inline View for ${1}
'''
model = ${2:${1}}
min_num = ${3:3}
max_num = ${4:20}
extra = ${5:1}
raw_id_fields = (${6},)
endsnippet
snippet tabularinline "Tabular Inline" b
class ${1}Inline(admin.TabularInline):
'''
Tabular Inline View for ${1}
'''
model = ${2:${1}}
min_num = ${3:3}
max_num = ${4:20}
extra = ${5:1}
raw_id_fields = (${6},)
endsnippet
snippet templateview "Generic Template View" b
class ${1:CLASS_NAME}(TemplateView):
template_name = "${2:TEMPLATE_NAME}"
endsnippet
snippet updateview "Generic Update View" b
class ${1:MODEL_NAME}UpdateView(UpdateView):
model = ${1:MODEL_NAME}
template_name = "${2:TEMPLATE_NAME}"
endsnippet
snippet dispatch "Dispatch View method" b
def dispatch(self, request, *args, **kwargs):
return super(${1:CLASS_NAME}, self).dispatch(request, *args, **kwargs)
endsnippet
snippet context "get_context_data view method" b
def get_context_data(self, **kwargs):
kwargs['extra_context'] = ${1:'New Value'}
return super(${2:CLASS_NAME}, self).get_context_data(**kwargs)
endsnippet
|