Skip to content

almahdi404/code-django

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django support for Visual Studio Code

Zero config , No need to switch to django-html !

highlighting

Features

1. Syntax Highlighting

Django template language syntax highlighting in html !

2. Jump to template

(ctrl+click)or(cmd+click) on path to jump to template from html or python file


If you love this extension, you could

Buy me a coffee

and support the future development and maintenance of this extension


3. Comment

Press (ctrl+shift+/)or(cmd+shift+/) to comment and uncomment

4. Snippets

Click to expand

admin / classes

Trigger Description
modeladmin Class - admin.ModelAdmin
simplelistfilter Class - admin.SimpleListFilter
stackedinline Class - admin.StackedInline
tabularinline Class - admin.TabularInline

admin / imports

Trigger Description
iadmin from django.contrib import admin
iadminsite from django.contrib.admin import AdminSite

admin / methods

Trigger Description
register Method - Register model without providing a ModelAdmin
registerd Method - Register model with providing a ModelAdmin using decorator
registerma Method - Register model providing a ModelAdmin

admin / options

Trigger Description
fieldsets Option - Model admin fieldsets

forms / classes

Trigger Description
form Class - forms.Form
modelform Class - forms.ModelForm

forms / fields

Trigger Description
fbool Field - forms.BooleanField
fchar Field - forms.CharField
fchoice Field - forms.ChoiceField
fcombo Field - forms.ComboField
fdate Field - forms.DateField
fdaterange Field - forms.DateRangeField. *PostgreSQL specific form fields*.
fdatetime Field - forms.DateTimeField
fdatetimerange Field - forms.DateTimeRangeField. *PostgreSQL specific form fields*.
fdecimal Field - forms.DecimalField
fduration Field - forms.DurationField
femail Field - forms.EmailField
ffile Field - forms.FileField
ffilepath Field - forms.FilePathField
ffloat Field - forms.FloatField
ffloatrange Field - forms.FloatRangeField. *PostgreSQL specific form fields*.
fip Field - forms.IPAddressField
fhstore Field - forms.HStoreField. *PostgreSQL specific form fields*.
fimg Field - forms.ImageField
fint Field - forms.IntegerField
fintrange Field - forms.IntegerRangeField. *PostgreSQL specific form fields*.
fip Field - forms.IPAddressField. This field has been deprecated since version 1.7 in favor of GenericIPAddressField.
fjson Field - forms.JSONField. *PostgreSQL specific form fields*.
fmochoice Field - forms.ModelChoiceField
fmomuchoice Field - forms.ModelMultipleChoiceField
fmuchoice Field - forms.MultipleChoiceField
fmuval Field - forms.MultiValueField
fnullbool Field - forms.NullBooleanField
fregex Field - forms.RegexField
fsdatetime Field - forms.SplitDateTimeField
fsimplearray Field - forms.SimpleArrayField. *PostgreSQL specific form fields*.
fslug Field - forms.SlugField
fsplitarray Field - forms.SplitArrayField. *PostgreSQL specific form fields*.
ftchoice Field - forms.TypedChoiceField
ftime Field - forms.TimeField
ftmuchoice Field - forms.TypedMultipleChoiceField
ftypedmuchoice Field - forms.TypedMultipleChoiceField
furl Field - forms.URLField
fuuid Field - forms.UUIDField

forms / imports

Trigger Description
iforms from django import forms
ipostgresff PostgreSQL specific forms fields

forms / methods

Trigger Description
clean_data Method - Form clean field
clean_password Method - Form confirm password
fsave Method - Form custom save method

imports / general

Trigger Description
iappforms Import - app.forms
iappmodels Import - app.models
iappviews Import - app.views
ireverse from django.urls import reverse
isettings from django.conf import settings
iusermodel from django.contrib.auth import get_user_model

models / classes

Trigger Description
manager Class - models.Manager
model Class - models.Model
modelfull Class - models.Model (full)
modelmixin Class - models.Model (mixin)
queryset Class - models.QuerySet

models / fields

Trigger Description
marray Field - models.ArrayField *PostgreSQL specific model fields*
mauto Field - models.AutoField
mbigauto Field - models.BigAutoField
mbigint Field - models.BigIntegerField
mbinary Field - models.BinaryField
mbool Field - models.BooleanField
mchar Field - models.CharField
mcoseint Field - models.CommaSeparatedIntegerField
mdate Field - models.DateField
mdatetime Field - models.DateTimeField
mdecimal Field - models.DecimalField
mduration Field - models.DurationField
memail Field - models.EmailField
mfile Field - models.FileField
mfilepath Field - models.FilePathField
mfk Field - models.ForeignKey
mfloat Field - models.FloatField
mgenericip Field - models.GenericIPAddressField
mimg Field - models.ImageField
mint Field - models.IntegerField
mip Field - models.IPAddressField
mjson Field - models.JSONField *PostgreSQL specific model fields*
mm2m Field - models.ManyToManyField
mnullbool Field - models.NullBooleanField
mo2o Field - models.OneToOneField
mphone Field - PhoneNumberField (django-phonenumber-field)
mposint Field - models.PositiveIntegerField
mpossmallint Field - models.PositiveSmallIntegerField
mslug Field - models.SlugField
msmallint Field - models.SmallIntegerField
mstore Field - models.HStoreField
mtext Field - models.TextField
mtime Field - models.TimeField
murl Field - models.URLField
musstate Field - USStateField (django-localflavor)
muuid Field - models.UUIDField
mxml Field - models.XMLField

models / imports

Trigger Description
iappmanagers Import - managers
imodels from django.db import models
ipostgresmf from django.contrib.postgres.fields
iuc For forwards compatibility, this decorator is available as of Django 1.4.2.
isignals from django.db.models.signals

models / methods

Trigger Description
get_absolute_url Method - get_absolute_url
receiver Method - receiver
str Method - __str__

python / imports

Trigger Description
inpdb Import - nose pdb debug tool
ipdb Import - ipdb debug tool
itraceback Import - traceback print exception
iul from __future__ import unicode_literals

python / methods

Trigger Description
__init__ Methods - __init__

templates / filters

Trigger Description
|add Filter - add:Arg
|addslashes Filter - addslashes
|capfirst Filter - capfirst
|center Filter - center:Arg
|cut Filter - cut:Arg
|date Filter - date
|default Filter - default:Arg
|default_if_none Filter - default_if_none:Arg
|dictsort Filter - dictsort:Arg
|dictsortreversed Filter - dictsortreversed:Arg
|divisibleby Filter - divisibleby:Arg
|escape Filter - escape
|escapejs Filter - escapejs
|filesizeformat Filter - filesizeformat
|first Filter - first
|floatformat Filter - floatformat
|force_escape Filter - force_escape
|get_digit Filter - get_digit
|iriencode Filter - iriencode
|join Filter - join:Arg
|last Filter - last
|length Filter - length
|length_is Filter - length_is:Arg
|linebreaks Filter - linebreaks
|linebreaksbr Filter - linebreaksbr
|linenumbers Filter - linenumbers
|ljust Filter - ljust
|lower Filter - lower
|make_list Filter - make_list
|phone2numeric Filter - phone2numeric
|pluralize Filter - pluralize
|pprint Filter - pprint
|random Filter - random
|rjust Filter - rjust
|safe Filter - safe
|safeseq Filter - safeseq
|slice Filter - slice:Arg
|slugify Filter - slugify
|stringformat Filter - stringformat
|striptags Filter - striptags
|time Filter - time:Arg
|timesince Filter - timesince:Arg
|timeuntil Filter - timeuntil:Arg
|title Filter - title
|truncatechars Filter - truncatechars:Arg
|truncatechars_html Filter - truncatechars_html:Arg
|truncatewords Filter - truncatewords:Arg
|truncatewords_html Filter - truncatewords_html:Arg
|unordered_list Filter - unordered_list
|upper Filter - upper
|urlencode Filter - urlencode
|urlize Filter - urlize
|urlizetrunc Filter - urlizetrunc
|wordcount Filter - wordcount
|wordwrap Filter - wordwrap
|yesno Filter - yesno:Arg

templates / imports

Trigger Description
li18n Load - i18n
ll10n Load - l10n
load Load - any
lstatic Load - static
ltz Load - tz

templates / tags

Trigger Description
autoescape {% autoescape %} {% endautoescape %}
autoescape_paste {% autoescape %} (paste) {% endautoescape %}
block {% block %} {% endblock %}
block_paste {% block %} (paste) {% endblock %}
blocktrans {% blocktrans %} {% endblocktrans %}
blocktrans_paste {% blocktrans %} (paste) {% endblocktrans %}
blocktrans_with {% blocktrans with %} {% endblocktrans %}
blocktrans_with_paste {% blocktrans with %} (paste) {% endblocktrans %}
blocktranslate {% blocktranslate %} {% endblocktranslate %}
blocktranslate_paste {% blocktranslate %} (paste) {% endblocktranslate %}
blocktranslate_with {% blocktranslate as %} {% endblocktranslate %}
blocktranslate_with_paste {% blocktranslate as %} (paste) {% endblocktranslate %}
comment {# #}
comment_block {% comment %} {% endcomment %}
comment_paste {% comment %} (paste) {% endcomment %}
csrf_token {% csrf_token %}
cycle {% cycle %}
debug {% debug %}
elif {% elif %}
else {% else %}
empty {% empty %}
endautoescape {% endautoescape %}
endblock {% endblock %}
endcomment {% endcomment %}
endfilter {% endfilter %}
endfor {% endfor %}
endif {% endif %}
endifchanged {% endifchanged %}
endspaceless {% endspaceless %}
endverbatim {% endverbatim %}
endwith {% endwith %}
extends {% extends '...' %}
filter {% filter %} {% endfilter %}
filter_paste {% filter %} (paste) {% endfilter %}
firstof {% firstof %}
for {% for %} {% endfor %}
for_paste {% for %} (paste) {% endfor %}
forempty {% forempty %} {% empty %} {% endfor %}
forempty_paste {% forempty %} (paste) {% empty %} {% endfor %}
if {% if %} {% endif %}
if_paste {% if %} (paste) {% endif %}
ifchanged {% ifchanged %} {% endifchanged %}
ifchanged_paste {% ifchanged %} (paste) {% endifchanged %}
ifelse {% if %} {% else %} {% endif %}
ifelse_paste {% if %} (paste) {% else %} {% endif %}
include {% include '...' %}
lorem {% lorem %}
now {% now %}
regroup {% regroup %}
regroup_example {% regroup %} (example)
resetcycle {% resetcycle %}
spaceless {% spaceless %} {% endspaceless %}
spaceless_paste {% spaceless %} (paste) {% endspaceless %}
static {% static '...' %}
static_paste {% static '(paste)' %}
tag {% tag %}
templatetag {% templatetag %}
translate {% translate '' %}
translate_paste {% translate '(paste)' %}
url {% url '...' %}
urlas {% url '...' as var %}
urlpk {% url '...' pk=object.pk %}
urlslug {% url '...' slug=object.slug %}
verbatim {% verbatim %} {% endverbatim %}
verbatim_paste {% verbatim %} (paste) {% endverbatim %}
widthratio {% widthratio %}
with {% with %} {% endwith %}
with_paste {% with %} (paste) {% endwith %}

templates / variables

Trigger Description
super Variable - block.super
username Variable - username
variable Variable - empty

templatetags / functions

Trigger Description
register_assignment_tag Custom Tag - Assignment
register_filter Custom Filter - Regular
register_inclusion_tag Custom Tag - Inclusion
register_simple_tag Custom Tag - Simple

templatetags / imports

Trigger Description
idefaultfilters from django.template.defaultfilters
ilib TemplateTags - Import Library

urls / imports

Trigger Description
iconf_urls Utility functions for use in URLconfs.
iconf_urls Utilityfunctions for use in URLconfs.
iurlresolvers *Deprecated since version 1.10* Utility functions.
iurls Utility functions for use in URLconfs.
iurls Utility functions for use in URLconfs.

urls / methods

Trigger Description
path_inline Route - path(route, view, name)
path_stack Route - path(route, view, name)
url_inline Route - url(regex, view, name)
url_stack Route - url(regex, view, name)
urlpatterns urlpatterns = []

urls / regexes

Trigger Description
repk Regex - PK URL
reslug Regex - Slug URL
reusername Regex - Username URL

views / classes

Trigger Description
createview View - class (CreateView)
deleteview View - class (DeleteView)
detailview View - class (DetailView)
listview View - class (ListView)
templateview View - class (TemplateView)
updateview View - class (UpdateView)

views / functions

Trigger Description
view View - function (render)
view_hr View - function (httpResponse)

views / imports

Trigger Description
igenericviews from django.views.generic
ihttpresponse from django.http import HttpResponse
imessages from django.contrib import messages
irender from django.shortcuts import render
ivdcache from django.views.decorators.http
ivdhttp from django.views.decorators.http

views / methods

Trigger Description
dispatch Method - dispatch
get_context_data Method - get_context_data
get_queryset Method - get_queryset

5. Autocompletion

Template, Staticfiles and Url autocompletion

highlighting highlighting

[!TIP] Whenever you create a template or register a new url you need to run the command Code Django: update cache or wait for the cache to update itself.

Installation

  1. From vscode

    • Launch VS Code Quick Open (Ctrl+P)
    • Paste ext install almahdi.code-django
    • Press enter
  2. From cli

    • Open terminal
    • Enter : code --install-extension almahdi.code-django

Known Issues

Currently no known issues

Release Notes

See all the release notes here in Changelog

Contributing

Pull requests are welcome.

Please see our contributing guide for more details

Credits

  • Snippets in this extension was initially copied from djaneiro

License

This project is licensed under MIT License


Enjoy! 😎