priority -50 # This files will define django snippets from sublime text djaneiro ########################################################################### # FORMS SNIPPETS # ########################################################################### snippet form "Form" class ${1:FORMNAME}(forms.Form): ${2:# TODO: Define form fields here} endsnippet snippet modelform "ModelForm" class ${1:MODELNAME}Form(forms.ModelForm): class Meta: model = $1 endsnippet snippet fbool "BooleanField (fbool)" ${1:FIELDNAME} = forms.BooleanField($2) endsnippet snippet fchar "CharField (fchar)" ${1:FIELDNAME} = forms.CharField($2) endsnippet snippet fchoice "ChoiceField (fchoice)" ${1:FIELDNAME} = forms.ChoiceField($2) endsnippet snippet fcombo "ComboField (fcombo)" ${1:FIELDNAME} = forms.ComboField($2) endsnippet snippet fdate "DateField (fdate)" ${1:FIELDNAME} = forms.DateField($2) endsnippet snippet fdatetime "DateTimeField (fdatetime)" ${1:FIELDNAME} = forms.DateTimeField($2) endsnippet snippet fdecimal "DecimalField (fdecimal)" ${1:FIELDNAME} = forms.DecimalField($2) endsnippet snippet fmail "EmailField (femail)" ${1:FIELDNAME} = forms.EmailField($2) endsnippet snippet ffile "FileField (ffile)" ${1:FIELDNAME} = forms.FileField($2) endsnippet snippet ffilepath "FilePathField (ffilepath)" ${1:FIELDNAME} = forms.FilePathField($2) endsnippet snippet ffloat "FloatField (ffloat)" ${1:FIELDNAME} = forms.FloatField($2) endsnippet snippet fip "IPAddressField (fip)" ${1:FIELDNAME} = forms.IPAddressField($2) endsnippet snippet fimg "ImageField (fimg)" ${1:FIELDNAME} = forms.ImageField($2) endsnippet snippet fint "IntegerField (fint)" ${1:FIELDNAME} = forms.IntegerField($2) endsnippet snippet fmochoice "ModelChoiceField (fmochoice)" ${1:FIELDNAME} = forms.ModelChoiceField($2) endsnippet snippet fmomuchoice "ModelMultipleChoiceField (fmomuchoice)" ${1:FIELDNAME} = forms.ModelMultipleChoiceField($2) endsnippet snippet fmuval "MultiValueField (fmuval)" ${1:FIELDNAME} = forms.MultiValueField($2) endsnippet snippet fmuchoice "MultipleChoiceField (fmuchoice)" ${1:FIELDNAME} = forms.MultipleChoiceField($2) endsnippet snippet fnullbool "NullBooleanField (fnullbool)" ${1:FIELDNAME} = forms.NullBooleanField($2) endsnippet snippet freg "RegexField (fregex)" ${1:FIELDNAME} = forms.RegexField($2) endsnippet snippet fslug "SlugField (fslug)" ${1:FIELDNAME} = forms.SlugField($2) endsnippet snippet fsdatetime "SplitDateTimeField (fsdatetime)" ${1:FIELDNAME} = forms.SplitDateTimeField($2) endsnippet snippet ftime "TimeField (ftime)" ${1:FIELDNAME} = forms.TimeField($2) endsnippet snippet ftchoice "TypedChoiceField (ftchoice)" ${1:FIELDNAME} = forms.TypedChoiceField($2) endsnippet snippet ftmuchoice "TypedMultipleChoiceField (ftmuchoice)" ${1:FIELDNAME} = forms.TypedMultipleChoiceField($2) endsnippet snippet furl "URLField (furl)" ${1:FIELDNAME} = forms.URLField($2) endsnippet ########################################################################### # MODELS SNIPPETS # ########################################################################### snippet model "Model" class ${1:MODELNAME}(models.Model): class Meta: verbose_name = "$1" verbose_name_plural = "$1s" def __str__(self): pass endsnippet snippet modelfull "Model (full)" class ${1:MODELNAME}(models.Model): ${2:# TODO: Define fields here} class Meta: verbose_name = "$1" verbose_name_plural = "$1s" def __str__(self): pass def save(self): pass @models.permalink def get_absolute_url(self): return ('') ${3:# TODO: Define custom methods here} endsnippet snippet mauto "AutoField (mauto)" ${1:FIELDNAME} = models.AutoField($2) endsnippet snippet mbigint "BigIntegerField (mbigint)" ${1:FIELDNAME} = models.BigIntegerField($2) endsnippet snippet mbool "BooleanField (mbool)" ${1:FIELDNAME} = models.BooleanField($2) endsnippet snippet mchar "CharField (mchar)" ${1:FIELDNAME} = models.CharField($2, max_length=${3:50}) endsnippet snippet mcoseint "CommaSeparatedIntegerField (mcoseint)" ${1:FIELDNAME} = models.CommaSeparatedIntegerField($2) endsnippet snippet mdate "DateField (mdate)" ${1:FIELDNAME} = models.DateField($2) endsnippet snippet mdatetime "DateTimeField (mdatetime)" ${1:FIELDNAME} = models.DateTimeField($2) endsnippet snippet mdecimal "DecimalField (mdecimal)" ${1:FIELDNAME} = models.DateTimeField($2) endsnippet snippet memail "EmailField (memail)" ${1:FIELDNAME} = models.EmailField($2) endsnippet snippet mfile "FileField (mfile)" ${1:FIELDNAME} = models.FileField($2) endsnippet snippet mfilepath "FilePathField (mfilepath)" ${1:FIELDNAME} = models.FilePathField($2) endsnippet snippet mfloat "FloatField (mfloat)" ${1:FIELDNAME} = models.FloatField($2) endsnippet snippet fk "ForeignKey (fk)" ${1:FIELDNAME} = models.ForeignKey($2) endsnippet snippet mip "IPAddressField (mip)" ${1:FIELDNAME} = models.IPAddressField($2) endsnippet snippet mimg "ImageField (mimg)" ${1:FIELDNAME} = models.ImageField($2) endsnippet snippet mint "IntegerField (mint)" ${1:FIELDNAME} = models.IntegerField($2) endsnippet snippet m2m "ManyToManyField (m2m)" ${1:FIELDNAME} = models.ManyToManyField($2) endsnippet snippet mnullbool "NullBooleanField (mnullbool)" ${1:FIELDNAME} = models.NullBooleanField($2) endsnippet snippet o2o "OneToOneField (o2o)" ${1:FIELDNAME} = models.OneToOneField($2) endsnippet snippet mphone "PhoneNumberField (mphone)" ${1:FIELDNAME} = models.PhoneNumberField($2) endsnippet snippet mposint "PositiveIntegerField (mposint)" ${1:FIELDNAME} = models.PositiveIntegerField($2) endsnippet snippet mpossmallint "PositiveSmallIntegerField (mpossmallint)" ${1:FIELDNAME} = models.PositiveSmallIntegerField($2) endsnippet snippet mslug "SlugField (mslug)" ${1:FIELDNAME} = models.SlugField($2) endsnippet snippet msmallint "SmallIntegerField (msmallint)" ${1:FIELDNAME} = models.SmallIntegerField($2) endsnippet snippet mtext "TextField (mtext)" ${1:FIELDNAME} = models.TextField($2) endsnippet snippet mtime "TimeField (mtime)" ${1:FIELDNAME} = models.TimeField($2) endsnippet snippet murl "URLField (murl)" ${1:FIELDNAME} = models.URLField($2) endsnippet snippet musstate "USStateField (musstate)" ${1:FIELDNAME} = models.USStateField($2) endsnippet snippet mxml "XMLField (mxml)" ${1:FIELDNAME} = models.XMLField($2) endsnippet ########################################################################### # VIEWS SNIPPETS # ########################################################################### snippet adminview "Model Admin View" 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" class ${1:MODEL_NAME}CreateView(CreateView): model = ${1:MODEL_NAME} template_name = "${2:TEMPLATE_NAME}" endsnippet snippet deleteview "Generic Delete View" class ${1:MODEL_NAME}DeleteView(DeleteView): model = ${1:MODEL_NAME} template_name = "${2:TEMPLATE_NAME}" endsnippet snippet detailview "Generic Detail View" class ${1:MODEL_NAME}DetailView(DetailView): model = ${1:MODEL_NAME} template_name = "${2:TEMPLATE_NAME}" endsnippet snippet listview "Generic List View" class ${1:MODEL_NAME}ListView(ListView): model = ${1:MODEL_NAME} template_name = "${2:TEMPLATE_NAME}" endsnippet snippet stackedinline "Stacked Inline" 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" 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" class ${1:CLASS_NAME}(TemplateView): template_name = "${2:TEMPLATE_NAME}" endsnippet snippet updateview "Generic Update View" class ${1:MODEL_NAME}UpdateView(UpdateView): model = ${1:MODEL_NAME} template_name = "${2:TEMPLATE_NAME}" endsnippet snippet dispatch "Dispatch View method" def dispatch(self, request, *args, **kwargs): return super(${1:CLASS_NAME}, self).dispatch(request, *args, **kwargs) endsnippet snippet context "get_context_data view method" def get_context_data(self, **kwargs): context = super(${1:CLASS_NAME}, self).get_context_data(**kwargs) return context endsnippet