Gedit as a Django IDE for Linux

Configuring gedit as a Django Text Editor in GNOME

That's right, gedit, the default text editor in GNOME, is actually a pretty bad ass IDE for Django web development. To those who have not really explored gedit it looks much like "Notepad" at first glance. Do not be fooled. gedit is incredibly fast, efficient, and stable. That makes it a great editor. Pair a great text editor with the right plugins and you got yourself a clean, lightweight, simple IDE.

Screenshot working with Django in gedit

In a nutshell...

  • Syntax highlighting for Python, Django templates, CSS, SQL, and many others
  • GUI interface to Django project management commands ( and
  • Edit remote files over FTP, SSH, etc.
  • Embedded terminal panel
  • Embedded Python shell panel
  • Embedded Database shell panel
  • Embedded Django development server panel
  • File browser side panel
  • Class and function browser side panel
  • Snippets manager with tab triggers
  • Many more plugins are available or write your own using Python

Gedit Built-In Features

Before activating any plugins gedit has a suite of features for development including syntax highlighting with configurable color schemes, undo/redo, search and replace, go to line, auto indentation, line numbers, right margin, line highlight, bracket matching, full UTF-8 support, and more. If you are new to gedit, open up 'Preferences' dialog and explore your options.

Anything outside of this core functionality as a text editor is achieved through a flexible plugin system. While there are far too many plugins usefull to Django developers to list them all, I will cover some of my favorite plugins I use when working on Django projects.

Django Project Plugin

A plugin that I wrote for gedit 3, gedit-django-project, adds GUI interfaces for and commands within gedit. Create new Django projects and apps, sync the database, start/stop the development server, load and dump data, and most of the other management commands you use the most are available directly in gedit. It also includes bottom tabs for the Django development server, Python shell console, and database shell.

Watch a video of gedit-django-project

Django project plugin for gedit

Django Template Syntax Highlighting

Gedit highlights (X)HTML markup out of the box. However, the .html we Django developers are typically working with are marked up with Django Template Language (DTL). No problem. Gedit uses GtkSourceView as it's text editing widget so adding new syntax highlighting is as simple as dropping an XML description file into a special folder.

The gedit-django-template-language project provides a dtl.lang file which adds "DTL" to the "Scripts" section.

I use a slightly modified version of this syntax so that it is labeled as "Django Template Language" under the "Markup" section. Download my dtl.lang file.

For gedit 3 put dtl.lang in:
For gedit 2 put dtl.lang in:

Django Template Language highlighting in gedit

Snippets Plugin and Django Snippets

The Snippets plugin comes shipped with gedit by default. Simply activate it in the Preferences dialog. This plugin allows you to create snippets of frequently used code and access them with "tab triggers". You type a specific word, hit the tab key, and your snippet pops into your document. You continue to use the tab key to fill in variables throughout the snippet.

Perhaps this is better illustrated with a video...

A collection of snippets is already available for Python. For Django you can download django-snippets-for-gedit and import them by selecting 'Manage Snippets' from the 'Tools' menu.

It may take a little bit of time to learn the tab triggers and get in the habbit if using them, however, it can really speed things up.

External Tools Plugin

Another built-in plugin, the External Tools Plugin, opens up endless possibilities. This plugin allows you to create little scripts of commands, passing in arguments from your gedit session such as the current document, selected text, current word, etc. This plugin is very versatile worthy of it's own entire article. For now, just imagine any sequence of commands you can think of can be integrated into the gedit interface.

For example, if you wanted a tool that opens your default web browser and searches the Django documentation for the word or phrase currently selected in gedit, you could create a tool that executes...

xargs -I '{}' gnome-open '"{}"'

How about analyzing your Python code using Pylint...


Sure, there are some file searching plugins for gedit. But, why not just use the GNOME search tool to find all files containing the word or phrase currently selected in gedit...

xargs -I '{}' gnome-search-tool --start --contains={}

And the list goes on and on. The sky is the limit. Go nuts. Have fun =)

File Browser Plugin and Remote Files

The File Browser plugin is also shipped with gedit. You just need to activate it in the gedit Preferences dialog. What may not be obvious at first is that you can browse and edit files over remote connections as well as the local filesystem.

Simply open up Nautilus, the GNOME file manager, and select 'Connect to Server...' from the 'File' menu (or run `nautilus-connect-server` from the command line). This will allow you to mount a remote filesystem. Once your remote server is mounted, you can add it to your bookmarked locations in Nautilus for quick access in the future by selecting 'Add Bookmark' from the 'Bookmarks' menu. You could also add the `nautilus-connect-server` command to the External Tools plugin if you want access from the gedit menu.

Connect to Server dialog

The File Browser plugin in gedit will display currently mounted filesystems, such as the one you just mounted using Nautilus, as well as all of your bookmarked places.

File Browser Plugin

Source Code Browser Plugin

Source Code Browser for gedit 3

While not exactly specific to Django, I could not live without my Source Code Broser plugin for gedit 3. This plugin will display your classes, methods, functions, and variables in a tree in the left pane. Clicking one of the items in the tree will jump to that location in the source code.

Did I Forget Any Plugins?

Yes I did. I only included a very few of the plugins I find most valuable for Django development, and only a fraction of the plugins I rely on every day. I also only included plugins written for gedit 3 since plugins written for gedit 2 will not work.

You can find many available plugins on the Gedit Plugins page. But, many folks write plugins and never list them. So don't forget to do a quick Google search for the plugin you're looking for, hit up the gedit-list mailing list, or pop into the #gedit IRC channel on

Roll Your Own Plugins

Can't find the plugin that does what you want? I'm going to go out on a limb here and assume that since you're developing Django applications, you consider yourself a Python programmer. Well, good news for you: gedit plugins can be written in Python. While some of the advanced user interfaces require a bit of GTK+ know-how, simple text manipulation plugins require only a small amount of GTK+ knowledge. Plus, GTK+ is pretty fun!

Writing Plugins for gedit 3 with Python

Did you enjoy Gedit as a Django IDE for Linux? If you would like to help support my work, A donation of a buck or two would be very much appreciated.
blog comments powered by Disqus
Linux Servers on the Cloud IN MINUTES