This is an old revision of the document!
Table of Contents
Use Geany for Django projects
The following ideas may help you to better work on Django (www.djangoproject.com) projects with Geany.
Better syntax highlighting for Django templates
You can configure Geany to highlight variables and template tags in Django templates. This helps a lot to differentiate between normal HTML code and Django template code in the template files.
By default, highlighting of Django template tags is disabled because it may cause glitches with other special sorts of HTML code and not everyone is using the Django template language.
To enable that special highlight, you need to adjust the HTML filetype definition file. Either create or edit the file /home/<username>/.config/geany/filedefs/filetypes.html and add the following few lines (or just adjust the [lexer_properties] section if it already exists):1)
[lexer_properties] lexer.html.django=1
More information about this file, its format and the path, e.g. on Windows, can be found in detail in the Geany manual, section Configuration Files.
Useful Django snippets
Tomasz Karbownicki 2) created some useful snippets for the filetypes Python and HTML to assist you working on Django code and templates.
For convenience, the relevant parts are copied below to easily be inserted into your Geany snippet configuration file. To do so, just open the configuration file in Geany by using Tools → Configuration Files → snippets.conf and either paste the contents below completely or extend the already existing sections Python and HTML.
[Python] # Django models # by Tomasz Karbownicki <tomasz@karbownicki.com> mclass=class %cursor%(models.Model):\n\t'''%cursor%'''\n\n\tdef __unicode__(self):\n\t\treturn self.XXXXX\n\n\tdef get_absolute_url(self):\n\t\treturn "/XXXXX/%s/" % self.slug\n\n\tclass Meta:\n\t\tverbose_name = "%cursor%"\n\t\tverbose_name_plural = "%cursor%" mchar=%cursor% = models.CharField(max_length=50, verbose_name=u'%cursor%') mint=%cursor% = models.IntegerField(verbose_name=u'%cursor%') mtext=%cursor% = models.TextField(verbose_name=u'%cursor%') mkey=%cursor% = models.ForeignKey(%cursor%, verbose_name=u'%cursor%') mimage=%cursor% = models.ImageField(upload_to='', verbose_name=u'%cursor%') mbool=%cursor% = models.BooleanField(verbose_name=u'%cursor%') mdate=%cursor% = models.DateField(verbose_name=u'%cursor%', help_text='Format daty: 2009-04-28') memail=%cursor% = models.EmailField(verbose_name=u'%cursor%') murl=%cursor% = models.URLField(verbose_name=u'%cursor%') mslug=%cursor% = models.SlugField(verbose_name=u'%cursor%', unique=True) [HTML] # Django templates if={% if %cursor% %}\n\t\n{% endif %} for={% for sth in %cursor% %}\n\t%cursor%\n{% endfor %} dv={{ %cursor% }} db={% %cursor% %} dbl={% block %cursor% %}\n\t%cursor%\n{% endblock %} trans={% trans "%cursor%" %} com={# %cursor% #} comm={% comment%} ecomm={% endcomment%}
More snippets for Python, HTML and many other languages can be found in this wiki, see Snippets.
More information about snippets in Geany can be found in detail in the Geany manual, section Snippets.
Tags
Tags for django (version 1.4.1) can be found here. For information on using tag files, see the Tags section of the Geany User Manual.