1
0
Fork 0
mirror of synced 2024-11-30 04:35:35 -05:00
ultimate-vim/sources_non_forked/vim-snippets/UltiSnips/django.snippets

362 lines
7.7 KiB
Text
Raw Normal View History

priority -50
2015-12-08 08:20:04 -05:00
# 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)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet ffilepath "FilePathField" b
${1:FIELDNAME} = forms.FilePathField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet ffloat "FloatField" b
${1:FIELDNAME} = forms.FloatField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet fip "IPAddressField" b
${1:FIELDNAME} = forms.IPAddressField($2)
endsnippet
2012-08-16 23:41:25 -04:00
2015-12-08 08:20:04 -05:00
snippet fimg "ImageField" b
${1:FIELDNAME} = forms.ImageField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet fint "IntegerField" b
${1:FIELDNAME} = forms.IntegerField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet fmochoice "ModelChoiceField" b
${1:FIELDNAME} = forms.ModelChoiceField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet fmomuchoice "ModelMultipleChoiceField" b
${1:FIELDNAME} = forms.ModelMultipleChoiceField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet fmuval "MultiValueField" b
${1:FIELDNAME} = forms.MultiValueField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet fmuchoice "MultipleChoiceField" b
${1:FIELDNAME} = forms.MultipleChoiceField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet fnullbool "NullBooleanField" b
${1:FIELDNAME} = forms.NullBooleanField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet freg "RegexField" b
${1:FIELDNAME} = forms.RegexField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet fslug "SlugField" b
${1:FIELDNAME} = forms.SlugField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet fsdatetime "SplitDateTimeField" b
${1:FIELDNAME} = forms.SplitDateTimeField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet ftime "TimeField" b
${1:FIELDNAME} = forms.TimeField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet ftchoice "TypedChoiceField" b
${1:FIELDNAME} = forms.TypedChoiceField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet ftmuchoice "TypedMultipleChoiceField" b
${1:FIELDNAME} = forms.TypedMultipleChoiceField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet furl "URLField" b
${1:FIELDNAME} = forms.URLField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
# 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__()
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
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}
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet mauto "AutoField" b
${1:FIELDNAME} = models.AutoField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet mbigint "BigIntegerField" b
${1:FIELDNAME} = models.BigIntegerField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet mbool "BooleanField" b
${1:FIELDNAME} = models.BooleanField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet mchar "CharField" b
${1:FIELDNAME} = models.CharField($2, max_length=${3:50})
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet mcoseint "CommaSeparatedIntegerField" b
${1:FIELDNAME} = models.CommaSeparatedIntegerField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet mdate "DateField" b
${1:FIELDNAME} = models.DateField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet mdatetime "DateTimeField" b
${1:FIELDNAME} = models.DateTimeField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet mdecimal "DecimalField" b
2016-03-14 06:04:57 -04:00
${1:FIELDNAME} = models.DecimalField(max_digits=${2:10}, decimal_places=${3:2})
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet memail "EmailField" b
${1:FIELDNAME} = models.EmailField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet mfile "FileField" b
${1:FIELDNAME} = models.FileField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet mfilepath "FilePathField" b
${1:FIELDNAME} = models.FilePathField($2)
endsnippet
2012-08-16 23:41:25 -04:00
2015-12-08 08:20:04 -05:00
snippet mfloat "FloatField" b
${1:FIELDNAME} = models.FloatField($2)
endsnippet
2012-08-16 23:41:25 -04:00
2015-12-08 08:20:04 -05:00
snippet fk "ForeignKey" b
${1:FIELDNAME} = models.ForeignKey($2)
endsnippet
snippet mip "IPAddressField" b
${1:FIELDNAME} = models.IPAddressField($2)
endsnippet
2012-08-16 23:41:25 -04:00
2015-12-08 08:20:04 -05:00
snippet mimg "ImageField" b
${1:FIELDNAME} = models.ImageField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet mint "IntegerField" b
${1:FIELDNAME} = models.IntegerField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet m2m "ManyToManyField" b
${1:FIELDNAME} = models.ManyToManyField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet mnullbool "NullBooleanField" b
${1:FIELDNAME} = models.NullBooleanField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet o2o "OneToOneField" b
${1:FIELDNAME} = models.OneToOneField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet mphone "PhoneNumberField" b
${1:FIELDNAME} = models.PhoneNumberField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet mposint "PositiveIntegerField" b
${1:FIELDNAME} = models.PositiveIntegerField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet mpossmallint "PositiveSmallIntegerField" b
${1:FIELDNAME} = models.PositiveSmallIntegerField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet mslug "SlugField" b
${1:FIELDNAME} = models.SlugField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet msmallint "SmallIntegerField" b
${1:FIELDNAME} = models.SmallIntegerField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet mtext "TextField" b
${1:FIELDNAME} = models.TextField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet mtime "TimeField" b
${1:FIELDNAME} = models.TimeField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet murl "URLField" b
${1:FIELDNAME} = models.URLField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet musstate "USStateField" b
${1:FIELDNAME} = models.USStateField($2)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
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)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet createview "Generic Create View" b
class ${1:MODEL_NAME}CreateView(CreateView):
model = ${1:MODEL_NAME}
template_name = "${2:TEMPLATE_NAME}"
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet deleteview "Generic Delete View" b
class ${1:MODEL_NAME}DeleteView(DeleteView):
model = ${1:MODEL_NAME}
template_name = "${2:TEMPLATE_NAME}"
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet detailview "Generic Detail View" b
class ${1:MODEL_NAME}DetailView(DetailView):
model = ${1:MODEL_NAME}
template_name = "${2:TEMPLATE_NAME}"
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet listview "Generic List View" b
class ${1:MODEL_NAME}ListView(ListView):
model = ${1:MODEL_NAME}
template_name = "${2:TEMPLATE_NAME}"
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
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},)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
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},)
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
snippet templateview "Generic Template View" b
class ${1:CLASS_NAME}(TemplateView):
template_name = "${2:TEMPLATE_NAME}"
2012-08-16 23:41:25 -04:00
endsnippet
2015-12-08 08:20:04 -05:00
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