sponsor Vim development Vim logo Vim Book Ad

vim-django : Support for Django through VIM

 script karma  Rating 30/9, Downloaded by 2782  Comments, bugs, improvements  Vim wiki

created by
Colin Wood
 
script type
utility
 
description
Vim-Django
Vim-Django is a vim script that helps manage a django app. It has wrapping's for the django-admin.py, your projects manage.py and some helper commands. It also has some quick ways to find templates, edit related files in a app, create new apps, and help manage django while using Vim.

Commands
DjangoAdmin will run any command through the django-admin.py command.

DjangoManage will run the management command for the project

DjangoProjectActivate will activate the project. This will go through your g:django_projects and find all the django projects. It will also set up DJANGO_SETTINGS_MODULE in your environment and the directory where the settings file is stored in your PYTHONPATH.

DjangoCreateApp will create a new app under your projects base. It will autocomplete the path. It just needs is a python path such as, colinbits.apps.new_app this will be created in the folder colinbits, apps, then run the django-admin.py to create the app there.

Mappings
There are mappings for easily editing related django files while working on a app. They all can be changed if you dont like how they are currently mapped. There are mappins for (v|views), (u|urls), (a|admin), and (t|tests). If you want to remap these you can call the function django#apps#edit('name_of_file.py', 'split') and it will open up the file it fineds in a split.

Configuration
g:django_projects is where your django projects are located.

g:django_activate_virtualenv when true will activate a virtualenv that starts with the same name. An example being. colinbits, is the site, and the virtuale env being colinbits.com.

Custom Activation of Projects
Since not everyone uses the default settings file vim-django will allow you to add a custom function to activate any project. In your vimrc you can define a function called ActivateProject it needs to accept one argument. From here you can have it activate the project.

Working with other Scripts
NERDTree: g:django_activate_nerdtree when set to 1 will launch nerdtree when activating the django project.

VirtualEnv: g:django_activate_virtualenv when set to 1 will activate the virtual env that starts with the same name.

Installing
I recommend using pathogen or vundle to install this script. Else, you can put the django.vim in the plug-ins directory. This script does require python to be compiled in.

Screen shots


FAQ
Working with virtualenv's
I actully reccomend installing vim-virtualenv
 
install details
Copy into your plugin directory or use vundle/pathogen
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
vim-django-1.0.tar.gz 1.0 2012-09-16 7.0 Colin Wood Vim Django stable release. If you have any issues please email me or create a new issue on github.com/cwood/vim-django. It would be greatly appreciated!
cwood-vim-django-0.3.1a-0-gd3cac29.tar.gz 0.3.1 2012-07-22 7.3 Colin Wood Keymappings to work with related files when in a app.
Extensions to work with NERDTree and VirtualEnv
Custom activation of projects
Misc bug fixes
cwood-vim-django-0.2.1a-0-ge339a41 (1).zip 0.2.1a 2012-06-25 7.3 Colin Wood Updated with documentation
Can now create apps using DjangoCreateApp
Some bug fixes and changing managment commands to better reflect the script name
vim-django.zip 0.0.1 2012-06-08 7.3 Colin Wood Initial upload
ip used for rating: 52.14.150.55

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github