Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added {Django, HTMLDjango} snippets #18

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions django/auto.snippet
@@ -0,0 +1 @@
${1:FIELDNAME} = models.AutoField()
1 change: 1 addition & 0 deletions django/bool.snippet
@@ -0,0 +1 @@
${1:FIELDNAME} = models.BooleanField(${2:default=True})
1 change: 1 addition & 0 deletions django/char.snippet
@@ -0,0 +1 @@
${1:FIELDNAME} = models.CharField(max_length=${2}${3:, blank=True})
1 change: 1 addition & 0 deletions django/comma.snippet
@@ -0,0 +1 @@
${1:FIELDNAME} = models.CommaSeparatedIntegerField(max_length=${2}${3:, blank=True})
1 change: 1 addition & 0 deletions django/date.snippet
@@ -0,0 +1 @@
${1:FIELDNAME} = models.DateField(${2:auto_now_add=True, auto_now=True}${3:, blank=True, null=True})
1 change: 1 addition & 0 deletions django/datetime.snippet
@@ -0,0 +1 @@
${1:FIELDNAME} = models.DateTimeField(${2:auto_now_add=True, auto_now=True}${3:, blank=True, null=True})
1 change: 1 addition & 0 deletions django/decimal.snippet
@@ -0,0 +1 @@
${1:FIELDNAME} = models.DecimalField(max_digits=${2}, decimal_places=${3})
1 change: 1 addition & 0 deletions django/email.snippet
@@ -0,0 +1 @@
${1:FIELDNAME} = models.EmailField(max_length=${2:75}${3:, blank=True})
1 change: 1 addition & 0 deletions django/file.snippet
@@ -0,0 +1 @@
${1:FIELDNAME} = models.FileField(upload_to=${2:path/for/upload}${3:, max_length=100})
1 change: 1 addition & 0 deletions django/filepath.snippet
@@ -0,0 +1 @@
${1:FIELDNAME} = models.FilePathField(path=${2:"/abs/path/to/dir"}${3:, max_length=100}${4:, match="*.ext"}${5:, recursive=True}${6:, blank=True, })
1 change: 1 addition & 0 deletions django/fk.snippet
@@ -0,0 +1 @@
${1:FIELDNAME} = models.ForeignKey(${2:OtherModel}${3:, related_name=''}${4:, limit_choices_to=}${5:, to_field=''})
2 changes: 2 additions & 0 deletions django/float.snippet
@@ -0,0 +1,2 @@
${1:FIELDNAME} = models.FloatField()

4 changes: 4 additions & 0 deletions django/form.snippet
@@ -0,0 +1,4 @@
class ${1:FormName}(forms.Form):
"""${2:docstring}"""
${3}

1 change: 1 addition & 0 deletions django/image.snippet
@@ -0,0 +1 @@
${1:FIELDNAME} = models.ImageField(upload_to=${2:path/for/upload}${3:, height_field=height, width_field=width}${4:, max_length=100})
1 change: 1 addition & 0 deletions django/int.snippet
@@ -0,0 +1 @@
${1:FIELDNAME} = models.IntegerField()
1 change: 1 addition & 0 deletions django/ip.snippet
@@ -0,0 +1 @@
${1:FIELDNAME} = models.IPAddressField()
1 change: 1 addition & 0 deletions django/m2m.snippet
@@ -0,0 +1 @@
${1:FIELDNAME} = models.ManyToManyField(${2:OtherModel}${3:, related_name=''}${4:, limit_choices_to=}${5:, symmetrical=False}${6:, through=''}${7:, db_table=''})
17 changes: 17 additions & 0 deletions django/model.snippet
@@ -0,0 +1,17 @@
class ${1:ModelName}(models.Model):
"""${2:docstring}"""
${3}

def __unicode__(self):
${4}

def save(self, force_insert=False, force_update=False):
${5}

@models.permalink
def get_absolute_url(self):
return ('${6:view_or_url_name}' ${7})

class Meta:
${8}

5 changes: 5 additions & 0 deletions django/modeladmin.snippet
@@ -0,0 +1,5 @@
class ${1:ModelName}Admin(admin.ModelAdmin):
${2}

admin.site.register($1, $1Admin)

1 change: 1 addition & 0 deletions django/nullbool.snippet
@@ -0,0 +1 @@
${1:FIELDNAME} = models.NullBooleanField()
3 changes: 3 additions & 0 deletions django/o2o.snippet
@@ -0,0 +1,3 @@
${1:FIELDNAME} = models.OneToOneField(${2:OtherModel}${3:, parent_link=True}${4:, related_name=''}${5:, limit_choices_to=}${6:, to_field=''})


1 change: 1 addition & 0 deletions django/posint.snippet
@@ -0,0 +1 @@
${1:FIELDNAME} = models.PositiveIntegerField()
1 change: 1 addition & 0 deletions django/possmallint.snippet
@@ -0,0 +1 @@
${1:FIELDNAME} = models.PositiveSmallIntegerField()
5 changes: 5 additions & 0 deletions django/r2r.snippet
@@ -0,0 +1,5 @@
return render_to_response('${1:template.html}', {
${2}
}${3:, context_instance=RequestContext(request)}
)

1 change: 1 addition & 0 deletions django/slug.snippet
@@ -0,0 +1 @@
${1:FIELDNAME} = models.SlugField(max_length=${2:50}${3:, blank=True})
1 change: 1 addition & 0 deletions django/smallint.snippet
@@ -0,0 +1 @@
${1:FIELDNAME} = models.SmallIntegerField()
4 changes: 4 additions & 0 deletions django/stackedinline.snippet
@@ -0,0 +1,4 @@
class ${1:ModelName}Inline(admin.StackedInline):
model = $1
extra = ${2:3}

5 changes: 5 additions & 0 deletions django/tabularinline.snippet
@@ -0,0 +1,5 @@
class ${1:ModelName}Inline(admin.TabularInline):
model = $1
extra = ${2:3}


1 change: 1 addition & 0 deletions django/text.snippet
@@ -0,0 +1 @@
${1:FIELDNAME} = models.TextField(${2:blank=True})
1 change: 1 addition & 0 deletions django/time.snippet
@@ -0,0 +1 @@
${1:FIELDNAME} = models.TimeField(${2:auto_now_add=True, auto_now=True}${3:, blank=True, null=True})
1 change: 1 addition & 0 deletions django/url.snippet
@@ -0,0 +1 @@
${1:FIELDNAME} = models.URLField(${2:verify_exists=False}${3:, max_length=200}${4:, blank=True})
2 changes: 2 additions & 0 deletions django/xml.snippet
@@ -0,0 +1,2 @@
${1:FIELDNAME} = models.XMLField(schema_path=${2:None}${3:, blank=True})

134 changes: 134 additions & 0 deletions htmldjango.snippets
@@ -0,0 +1,134 @@
# Generic Tags
snippet %
{% ${1} %}${2}
snippet %%
{% ${1:tag_name} %}
${2}
{% end$1 %}
snippet {
{{ ${1} }}${2}
# Template Tags

snippet autoescape
{% autoescape ${1:off} %}
${2}
{% endautoescape %}
snippet block
{% block ${1} %}
${2}
{% endblock %}
snippet #
{# ${1:comment} #}
snippet comment
{% comment %}
${1}
{% endcomment %}
snippet cycle
{% cycle ${1:val1} ${2:val2} ${3:as ${4}} %}
snippet debug
{% debug %}
snippet extends
{% extends "${1:base.html}" %}
snippet filter
{% filter ${1} %}
${2}
{% endfilter %}
snippet firstof
{% firstof ${1} %}
snippet for
{% for ${1} in ${2} %}
${3}
{% endfor %}
snippet empty
{% empty %}
${1}
snippet if
{% if ${1} %}
${2}
{% endif %}
snippet else
{% else %}
${1}
snippet ifchanged
{% ifchanged %}${1}{% endifchanged %}
snippet ifequal
{% ifequal ${1} ${2} %}
${3}
{% endifequal %}
snippet ifnotequal
{% ifnotequal ${1} ${2} %}
${3}
{% endifnotequal %}
snippet include
{% include "${1}" %}
snippet load
{% load ${1} %}
snippet now
{% now "${1:jS F Y H:i}" %}
snippet regroup
{% regroup ${1} by ${2} as ${3} %}
snippet spaceless
{% spaceless %}${1}{% endspaceless %}
snippet ssi
{% ssi ${1} %}
snippet trans
{% trans "${1:string}" %}
snippet url
{% url ${1} as ${2} %}
snippet widthratio
{% widthratio ${1:this_value} ${2:max_value} ${3:100} %}
snippet with
{% with ${1} as ${2} %}
# Template Filters

# Note: Since SnipMate can't determine which template filter you are
# expanding without the "|" character, these do not add the "|"
# character. These save a few keystrokes still.

# Note: Template tags that take no arguments are not implemented.

snippet add
add:"${1}"
snippet center
center:"${1}"
snippet cut
cut:"${1}"
snippet date
date:"${1}"
snippet default
default:"${1}"
snippet defaultifnone
default_if_none:"${1}"
snippet dictsort
dictsort:"${1}"
snippet dictsortrev
dictsortreversed:"${1}"
snippet divisibleby
divisibleby:"${1}"
snippet floatformat
floatformat:"${1}"
snippet getdigit
get_digit:"${1}"
snippet join
join:"${1}"
snippet lengthis
length_is:"${1}"
snippet pluralize
pluralize:"${1}"
snippet removetags
removetags:"${1}"
snippet slice
slice:"${1}"
snippet stringformat
stringformat:"${1}"
snippet time
time:"${1}"
snippet truncatewords
truncatewords:${1}
snippet truncatewordshtml
truncatewords_html:${1}
snippet urlizetrunc
urlizetrunc:${1}
snippet wordwrap
wordwrap:${1}

3 changes: 0 additions & 3 deletions javascript/for.snippet

This file was deleted.

3 changes: 0 additions & 3 deletions javascript/fun.snippet

This file was deleted.

1 change: 0 additions & 1 deletion javascript/if.snippet

This file was deleted.

4 changes: 0 additions & 4 deletions javascript/ife.snippet

This file was deleted.

3 changes: 0 additions & 3 deletions javascript/proto.snippet

This file was deleted.

1 change: 0 additions & 1 deletion javascript/timeout.snippet

This file was deleted.

2 changes: 1 addition & 1 deletion python/class.snippet
@@ -1,2 +1,2 @@
class ${1:``Snippet_PythonClassNameFromFilename()``}(${2:data}):
class ${1:`Snippet_PythonClassNameFromFilename()`}(${2:data}):
${3}
2 changes: 0 additions & 2 deletions python/def.snippet

This file was deleted.

3 changes: 0 additions & 3 deletions python/for.snippet

This file was deleted.

2 changes: 0 additions & 2 deletions python/ifmain.snippet

This file was deleted.