config/.vim/eclim/doc/vim/python/django.txt

262 lines
5.8 KiB
Plaintext
Raw Normal View History

*vim-python-django*
Django
******
*:DjangoManage*
Django manage.py
================
For each project you create with the django framework, django provides
you with a manage.py which can be used to perform various tasks. To
make the invocation of the manage.py script even easier, eclim
provides the command :DjangoManage which can be invoked from any file
in the same directory as your manage.py or in any of the child
directories.
:DjangoManage supports all the same commands as manage.py and supports
command line completion of command names and app names where
supported.
Several of the manage.py commands simply perform an action without
generating much if any output. However there is also a set of
commands which generate sql statements. For all of these commands,
instead of just running the command in a shell, :DjangoManage will run
the command and populate a new buffer with the resulting output and
set the proper file type.
Configuration
=============
Vim Variables
*g:EclimPythonInterpreter*
- g:EclimPythonInterpreter = 'python'
*g:EclimDjangoAdmin*
- g:EclimDjangoAdmin = 'django-admin.py'
Django python support
=====================
*:DjangoTemplateOpen*
Locating templates
The command :DjangoTemplateOpen supports finding and opening a
template referenced under the cursor.
Ex.
>
# w/ cursor on 'mytemplates/mytemplate.html'
return render_to_response('mytemplates/mytemplate.html', ...)
<
*:DjangoViewOpen*
Locating views
The command :DjangoViewOpen supports finding and opening a view
referenced under the cursor.
Ex.
>
# w/ cursor on 'myproject.myapp.views' or 'my_view' on the second line.
urlpatterns = patterns('myproject.myapp.views',
(r'^$', 'my_view'),
)
<
*:DjangoContextOpen*
Contextually locate file
The command :DjangoContextOpen supports executing :DjangoViewOpen,
:DjangoTemplateOpen, or :PythonFindDefinition depending on the context
of the text under the cursor.
*htmldjango*
Django html template support
============================
Syntax
Vim ships with a syntax file for django html template files, but eclim
builds on that base to support highlighting of user defined tags and
filters (see the configuration section below.
Indent
Using the same settings as the enhanced syntax file, eclim also ships
with an indent script which provides indentation support all of the
default django tags and any user defined tags that have been
configured.
Match It
Again, using the same set of variables, eclim sets the necessary
variables to allow proper matchit.vim support for django default and
user defined tags.
End Tag Completion
Using the |g:HtmlDjangoUserBodyElements| setting along with the
pre-configured default list of body elements, eclim includes support
for auto completion of ending template tags when you type an '{%e' or
'{% e'.
*:DjangoFind*
Contextual Find
While editing django html templates, the command :DjangoFind which
will attempt to locate the relevant resource depending on what is
under the cursor.
- If on a user defined tag, attempt to find the tag definition within
the python tag definition file.
Ex.
>
{# w/ cursor on 'mytag' #}
{% mytag somearg %}
<
- If on a user defined filter, attempt to find the filter definition
within the python filter definition file.
Ex.
>
{# w/ cursor on 'myfilter' #}
{{ somevalue|myfilter }}
<
- If on the tag/filter definition portion of of a 'load' tag, attempt
to find the definition file.
Ex.
>
{# w/ cursor on 'mytags' #}
{% load mytags %}
<
- If on a reference to a template for ethier an 'extends' or 'include'
tag, attempt to find that template file.
Ex.
>
{# w/ cursor on 'include/mytemplate.html' #}
{% include "include/mytemplate.html" %}
<
- If on static file reference, as defined in a 'src' or 'href'
attribute of an element, attempt to find that static file.
Ex.
>
{# w/ cursor on '/css/my.css' #}
<link rel="stylesheet" href="/css/my.css" type="text/css" />
<
Note: this functionality requires that g:EclimDjangoStaticPaths is
set to a list of absolute or django project relative (relative to
directory containing manage.py and settings.py) directories.
Ex.
>
let g:EclimDjangoStaticPaths = ["../static/"]
<
Configuration
=============
Vim Variables
*g:HtmlDjangoUserBodyElements*
- g:HtmlDjangoUserBodyElements - List of lists, where each list
contains the name of the start and end tag, as well as any
intermediary tags of any custom tags which have a body.
Ex.
>
let g:HtmlDjangoUserBodyElements = [
\ ['repeat', 'endrepeat'],
\ ['try', 'except', 'finally', 'endtry'],
\ ]
<
This setting is used for indentation of the custom tag's body, as
well as arguments for proper matchit support, end tag completion,
and syntax highlighting.
*g:HtmlDjangoUserTags*
- g:HtmlDjangoUserTags - This setting is a list of any non-body tags
which don't require indentation or matchit support. The items
configured here will be used for syntax highlighting.
*g:HtmlDjangoUserFilters*
- g:HtmlDjangoUserFilters - This settings contains a list of any user
defined django filters. It is currently used for syntax
highlighting.
*g:HtmlDjangoCompleteEndTag*
- g:HtmlDjangoCompleteEndTag (Default: 1) - When set to 0, disables
the auto completion of end tags.
*g:EclimDjangoStaticPaths*
- g:EclimDjangoStaticPaths - Used as a list of directories to search
when looking for static files (js, css, etc). Expected to be a list
of absolute or django project relative (relative to directory
containing manage.py and settings.py) directories.
Ex.
>
let g:EclimDjangoStaticPaths = ["../static/"]
<
*g:EclimDjangoFindAction*
- g:EclimDjangoFindAction (Default: "split") - For :DjangoFind and
:DjangoTemplateOpen, used as the action to perform on the file
found.
vim:ft=eclimhelp