shabda
Comments
Reactions

Tools of Pro Django developer - aka What powers dinette and almost every app we write.

By : Shabda Raaj

There are some tools and apps which we use with almost all apps we write, and in particular which, we used for dinette. Here they are broken into useful during development, and (also) useful post development.

During Development

  1. Ipython and ipdb
  2. South
  3. Django test utils
  4. Django extensions
  5. Django debug toolbar
Ipython and ipdb

Ipython is a enhanced shell for python. Ipdb similarly add extra capacity to the builtin pdb debugger. It is extremely convenient to drop into a ipython shell right where a complex piece of code is being hit.

from IPython.Shell import IPShellEmbed
ipython = IPShellEmbed()
ipython()

Of course this does not allow you to step through, so if you want to step through your code, you need to do

import ipdb
ipdb.set_trace()

Of course, you can just do pdb.set_trace(), but with tab completion and syntax highlighting, using ipdb is a no brainer.

South

South adds schema migration to Django. It has lot of advanced options, but just three command will get you along way.

Convert a normal app to use the south way.

./manage.py convert_to_south

Once you have made any changes to your apps model, write a new migration which can update the database to latest models.py

./manage.py startmigration appname nameofmigration --auto

Once you have written a migration, write a command to update the db.

./manage.py migrate appanme
Django test utils

When you are running tests, a huge time sink is the time spent dropping and recreating tests. You might add just a single test, and the default Django testrunner will spend a huge time recreating the database. Enter manage.py quicktest which reuses databases between test runs. One of the side effects of this is that if you modify models.py between test runs you should manually recreate the database.

The tests (or whatever little of it exists) for Dinette were written using testutils' testmaker.

Django extensions

Django extensions, (earlier Django command extensions) is a app which adds extra commands to manage.py. It has lot of goodies, but just ./manage.py shell_plus makes it worthwhile. (It imports all the models from all the apps automatically).

Get the full list at Github

Django debug toolbar

I do not personally use it but some people on our team swear by it.

After development

  1. Django-pagination
  2. sorl-thumbnails
  3. django-compressor
  4. Haystack
Django-pagination

I have decided on a standard way to build apps which need pagination. a. Build apps without pagination. b. The night before release spend an hour and add pagination to all pages. Really this is all you need

{% load pagination tags %}
{% autopaginate queryset %}
....
{% paginate %}

There is no change required to the views.

sorl-thumbnails

To thumbnail an image.

{% thumbnail image size %}

"Things should be as simple as possible, but not simpler."

django-compressor

During development we work with multiple unminified js and css files. Django-compressor takes care of minifying and compressing it when we deploy. All we need to do is,

{% compress css %}
...
all css files
....
{% endcompress %}

{% compress js %}
...
all js files
....
{% endcompress %}
Haystack

Haystack is "modular search for Django". It make writing search views as easy as writing the admin. You declaratively tell what fields you want to search on, and Haystack can take care of creating and updating the index, and providing a generic view to handle the search. Check a search view written using Haystack http://uswaretech.com/forum/search/?q=django


To everyone who contributed to these apps, thanks. Django development won't be the same without these great tools. This post was inspired by Kevin Fricovsky's post post, The apps that power Django-Mingus and is stolen about 50% from there. Thanks. :)


We build Amazing web apps, and we can build it for you. Contact us today.


Related Posts


Can we help you build amazing apps? Contact us today.

Topics : python tips

Comments

zach

Nice list of django tools, but I think your missing a few things. First off there should be some mention about the environment your working in, any *nix based OS (Ubuntu, Gentoo, OSX, Chrome, etc) is going to open up a lot of tools when your start using the command line. If you're forced to use Windows at least use CYGWIN or something to get these tools they help out a lot. Also GNU Screen should be mentioned as well as virtualenv because they allow you to isolate your environment and keep different processes running (django shell, test, dev server, etc...), along with whatever SCM (git, hg, svn) you use. All of these tools make developing applications with django much more easier, and help you become a more proficient developer.

commmenttor
shabda

@zach: You are correct of course,

BUt I dont use windows, so I dont know about cygwin. :)
Screen and SCM are Tools any pro dev are using.. Also I <3 Git, and but am tired of git fandom so dont want to write another of those.
We already have an article on virtualenv.

commmenttor
zach

@shabda I agree, I'm getting sick of the git fandom myself, but I've accepted the fact that I'm a victim of it and the idea of distributed source control.

Anyways, when I was writing the last comment I was trying to think of some other useful applications that I've found that help me develop django apps. One thing that I find useful is django-command-extensions (http://code.google.com/p/django-command-extensions/) when developing an application. I tend to leave it out when I'm deploying an project to a production server, I don't use the extra database fields or the admin extensions it gives you. Also along the same lines as Haystack, if your in need of a quick REST Api, I've found a project called django-piston (http://bitbucket.org/jespern/django-piston/overview/) which lets you build REST api's quickly and easily.

commmenttor
shabda

Zach: True. settings.py runing uswaretech.com has a swicth on DEBUG for django-extensions and debug toolbar. So, We use it similarly. Piston is very useful, we just didn't use it during Dinette. :)

commmenttor
pro tools courses

Session information are connected along that can be read as they contain the notices being provided during time. Also, during plenty of duration of pro resources if there comes in any sort of concern you can ask by email. You will get the immediate reaction and then you will get better idea.
Lovely information here thanks for update....

commmenttor
Getting Your Ralph Lauren T-Shirts f¨¹r g¨¹nstige

Tools of Pro Django developer - aka What powers dinette and almost every app we write. - Agiliq Blog | Django web app development

commmenttor
Terry

This article is pretty good to read. Great!!
Thank you for sharing, may I post it on my Tumblr to share to my families?

commmenttor

Reactions

uswaretech

New post. Tools of pro Django developers http://bit.ly/4EON8X

This comment was originally posted on Twitter

uswaretech_blog

Tools of Pro Django developer – aka What powers dinette and almost every app we write.: There are some tools an.. http://bit.ly/8hTmNh

This comment was originally posted on Twitter

KamiSLO

Useful tools and applications for #django developers http://bit.ly/4nW6U8

This comment was originally posted on Twitter

dannyroa

Tools of Pro Django developer – aka What powers dinette and almost every app we write. — The Usware Blog http://bit.ly/6DAEB6

This comment was originally posted on Twitter

steyblind

Very delightful post, Tools of a Pro Django developer with v. concise code/command examples http://bit.ly/6cMCNU #django

This comment was originally posted on Twitter

kuryaki

Tools of Pro Django developer – aka What powers dinette and almost every app we write. http://bit.ly/5umI4p

This comment was originally posted on Twitter

joshuajonah

Lies. I am a pro Django developer. I use South every once in a while, but never use the others :D

This comment was originally posted on Reddit

ubernostrum

I use South. Don’t use any of the others, though — my idea of "pro" tools is stuff like virtualenv, Fabric, etc.

This comment was originally posted on Reddit

kingkilr

Most of that stuff is "shit you damn well better be using" if you develop in Python professionally.

This comment was originally posted on Reddit

shabda

It is a bit tounge in cheek, where pro == me. :)

This comment was originally posted on Reddit

ubernostrum

As I said, I use South, and *none of the other tools you listed*. That included ipython and ipdb: I don’t use them. I use the plain old standard Python interactive interpreter, and I don’t use a debugger, period.

This comment was originally posted on Reddit

shabda

Also I would assume you are using ipython (and with high probablility, ipdb). If not then what is the alternative?

This comment was originally posted on Reddit

djangostories

Tools of Pro Django developer – aka What powers dinette and almost every app we write. — The Usware Blog – Djan.. http://bit.ly/7QSnyB

This comment was originally posted on Twitter

scorpion032

I don’t use a debugger; but I use IPythonEmbed often. The advantage of using IPythonEmbed, at arbitrary place in the code is not appreciated enough. Say I want to use a inlineformset_factory with ordering and make order a hidden field. Now the docs, being how good they are, don’t mention about the can_order=True parameter. I’d in this case, place an ipython shell in the form `__init__` after calling it’s super. Now, I can, **in the shell goodness** examine all the parameters, at that moment. I find that, each form has a new field `ORDER` (I couldn’t have probably guessed it, all caps?), and can modify it’s widget to make it hidden, and exit. It works, I can use the same thing in the code. Heck I could even log all that I write in the ipython shell or get it on shell by hist -n. I can also see the source and the doc string of formset, or any other object by ? and ??. Throw ipython where you want to code, **play on the shell**, now having exactly understood what you need to do by playing enough, code; I find it invaluable.

This comment was originally posted on Reddit

scorpion032

So, it is ‘Tools of _a_ pro django developer’?

This comment was originally posted on Reddit

jsuntheimer

Tools of Pro Django developer – aka What powers dinette and almost every app we write. — The Usware Blog – Djan.. http://bit.ly/8bCIi7

This comment was originally posted on Twitter

delicious50

Tools of Pro Django developer – aka What powers dinette and almost every app we write. — The Usware Blog – Django We http://bit.ly/8JHDVK

This comment was originally posted on Twitter

durden20

@agorist BTW useful article i read about django debug tools, etc. today: http://bit.ly/6cMCNU

This comment was originally posted on Twitter

Post a comment Name :

Email :

Your site url:

Comment :

© Agiliq, 2009-2012