Dan Bader

Sublime Text plugin review: Djaneiro

A review of Djaneiro, a Sublime Text plugin for Django development.

I’ll admit I was skeptical at first when a friend of mine recommended Djaneiro to enhance my Django development workflow in Sublime Text.

I’d been happy with the Python development setup I built for myself over the years and I didn’t really understand what Djaneiro was going to add to that.

But when I tried out Djaneiro I was impressed how helpful it turned out to be! I decided to write another Sublime Text plugin review to share my findings.

Djaneiro’s main selling points are adding:

  • syntax highlighting for Django HTML templates; and
  • code completion snippets for Django HTML templates and Python files.

In this review I’ll explain how Djaneiro can make your Django development workflow more productive and I’ll go over the pros and cons of the plugin as I experienced them. After that I’ll take a look at alternatives to Djaneiro in the Sublime Text plugin landscape. At the end I’ll share my final verdict and rating.

Pros

Syntax highlighting for Django templates: In its default configuration Sublime Text doesn’t have syntax definitions for Django’s HTML templating syntax.

This means that typos and syntax errors in templates are harder to catch visually. As you can see in the screenshot below (in the editing pane on the left), the standard HTML syntax highlighting in Sublime Text 3 uses a uniform white color for Django’s template tags.

Djaneiro adds a HTML (Django) syntax that properly highlights Django’s template tags. As you can see in the right-hand editing pane in the screenshot, proper syntax highlighting makes these templates quite a bit easier to read. Also, syntax errors and typos stand out more due to the proper highlighting.

This simple change adds a lot of value – I found that I was making fewer typos in my templates with Djaneiro’s syntax highlighting. Also, templates seemed easier to read and scan quickly with Djaneiro installed.

Improved syntax highlighting for Django Python files: Djaneiro also makes some small tweaks to the default Python syntax highlighting. For example, it knows the standard Django settings constants like INSTALLED_APPS and highlights them differently so that they stand out more and typos are easier to find.

This also happens for things like field definitions when writing Django model classes, which I found handy. In summary I found that the syntax highlighting changes introduced by Djaneiro make it easier to grasp the structure of the code I’m writing.

Code completion snippets for Django templates and Python files: Another helpful feature provided by Djaneiro is a library of pre-made code completion snippets for common Django code and patterns.

For example, you can insert an {% if _____ %} {% endif %} block by typing if as an abbreviation and hitting the auto-complete key (Tab by default). You can see a quick demo of that in the screenshot below. Generally, I found the list of snippets included with Djaneiro to be comprehensive and well-chosen.

Besides snippets for Django HTML templates Djaneiro also includes a snippet library for Django Python code. These snippets let you quickly scaffold out whole view definitions or a barebones model classes, for example.

Once you’ve gotten used to these snippets they can save you a lot of typing. Be sure to check out the full list of snippets in the Djaneiro README.

Cons

Snippets might get in the way: Because Djaneiro adds quite a substantial number of new code snippets I found myself triggering some of them accidentally, especially in the beginning. I really don’t want to hold this up against Djaneiro because the snippets do add a lot of value once I learned to use them well.

It’s possible to disable individual code snippets in Sublime Text but unfortunately this process is a bit involved.

If you find that the snippets get in your way occasionally you can temporarily switch them off by selecting a different syntax highlighting definition. Just open the Sublime Text Command Palette, type Set syntax, and select the default HTML or Python syntax.

Alternatives

There are a few more Django-specific plugins available on Package Control but Djaneiro seems to be the most popular and also the most powerful of the pack.

The verdict

I’ve grown quite fond of Djaneiro since I started using it. I immediately loved the improved syntax highlighting for Django templates and I’d say Djaneiro is worth installing for that feature alone.

Once I’d gotten the hang of Djaneiro’s code snippets and their shortcodes I felt a noticeable improvement in my productivity. The snippets added by Djaneiro cover many things I encountered in day to day Django development. It’s great not having to go through the work of writing these snippets myself.

I’d recommend any Django developer using Sublime Text to at least try out Djaneiro for a few days. There aren’t any substantial downsides to it and I’m sure it will make you more productive. You can install Djaneiro via Package Control.

🐍 🐍 🐍 🐍 🐍 (5 out of 5 snakes)

Your Shortcut to a Productive Python Setup with Sublime Text: Get a professional Sublime Text setup for writing Python that makes you more productive and will be an absolute joy to use. » Click here to learn more

5 Sublime Text Plugins to Boost Your Python Productivity

Free 5-day class—just enter your email address below:

This article was filed under: django, plugin-review, python, and sublimetext.

Related Articles:
Latest Articles: ← Browse All Articles