Serving static files in Django

By : Akshar Raaj

Serving static files, especially during development, is frequently a pain point. In this post, we will discuss the various settings and directory structure and how they interact with each other. Let's start with development when you have DEBUG = True.

We will create a Django project from scratch so that we are fully aware about what file in what directory we are talking about. So, this blog post will be a little longer than it should be. We will try these things with Django 1.4, but these will work on Django 1.3 as well. I have not tested ...

more info..
Topics : django static

Two Scoops of Django: Review

By : Shabda Raaj

Django best practices

Two scoops of Django is the new book on Django best practices by Daniel Greenfeld and Audrey Roy. I just finished reading it and found it extremely useful.

The book is a collection of tips, their justification and code organized in logical areas. I have been using Django since 2008, but I still found a few tips which were new to me and many which served as good reminder. At about 200 pages, its comprehensive but not overwhelming. If you are an advanced Djangonaut, you can read it in a weekend (And you probably are using all its recommendations anyway ...

more info..

Introduction to Python Workshop on February 15th, 2013

By : Thejaswi Puthraya

We are conducting an "Introduction to Python" workshop at our office on February 15th, 2013 (Friday) between 5-8PM IST. This workshop is geared towards those who are planning to learn python.


  • Language features
  • Variables
  • Built in data structures
  • Functions
  • Object Oriented Programming
  • Demo writing a simple program

Prerequisites to attend this session:

  • A laptop with any linux flavour (OR) a laptop with Python installed in it.

Register for the workshop by filling up the form.

more info..
Topics : python training

Easy client side form validations for Django: Django Parsley

By : Shabda Raaj

Parsleyjs is a JavaScript library to do client side data validations. It does this in a non-intrusive way via adding a data-* attributes to form fields. Check it out, it's really slick.

Django forms do a great job of server side data validations. By integrating Parsley with Django form, you get good client side data validations as well. Get the app here.

Some design considerations

When I started writing this app I wanted to make it really easy to use. My first thought was to make this a filter or a template tag which would have allowed you to ...

more info..
Topics : django

MoreApps - Android Library Project: Open Sourced

By : Shabda Raaj

If you have a portfolio of apps, you probably want to cross promote them.

We are open sourcing an Android Library Project to make this possible. Get the code. This provides an Activity which you can show with a Grid of your apps.

How to use it

Add this MoreAppsLibrary project(library) as a dependency in the Android Application project you are implementing.
Add the following code in your AndroidManifest.xml:

<activity android:name=""
          android:label="More Apps">

Perform an Intent to start the MoreAppsActivity; make sure to putExtra("package", getPackageName());, this ensures that ...

more info..
Topics : android open-source

Tutorial: Building a Chrome app

By : bhaskar

This is a hands on tutorial about How to build chrome apps, with examples of two Chrome apps we published recently. Lets get started.

Chrome apps are of two types:

  • Extensions : They extend the functionality of Google chrome and the websites. They have little or no UI. Ex:Password Generator . Source code : Github
  • Apps: These are separate apps and appear just like any other website. Ex: To Do List. Source Code : Github

Depending on our requirement, we need to decide what kind of app we need to build.

Extension: Password Generator

Installation :

Visit the link Password Generator using google-chrome browser ...

more info..

Password Generator App: Open Sourced

By : Shabda Raaj


We are open sourcing a few tools we developed recently. Here is the second one.

Password Generator Chrome Extension

Install it from chrome webstore
Here are the docs


A completely client side password generator.

What is it

Its a chrome app to generate unique passwords for each site. Depending upon the domain and a master password a unique password is generated. It doesn't need any server and everything happens on the client side.


I want to use a unique password for each website. However, I don't want to use lastpass/1password as I find their ...

more info..

Android Fragments 101

By : ikram - Programmer, Web Hacker, App Developer, Techie & Geek.

Prerequisite: You are already aware of the basics of building a HelloWorld in Android and know how to use the APIs provided in the support library.

The code example is available on github.

Ever wanted a code snippet from an Activity to be available to other activities? Perhaps a Button or a ListView, maybe a Layout or any View/ViewGroup for that matter? Fragments let us do just that.

Necessity is the mother of invention.
Before understanding what Fragments are and how they work, we must first realize their existence in the first place.

The Problem

Suppose we have an ...

more info..

Understanding decorators

By : Akshar Raaj

Understanding decorators in Python

We will divide this post into two topics

  1. Functions are objects and they can be passed around.
  2. Writing few decorators

As usual, I will be trying out the code in ipython and I suggest you to do the same.

Functions can be passed around similar to any other object in Python.

If you are already familiar with this, you can skip to next section.

Let's first write a class.

>>> class A(object):
...     def __init__(self, a):
...         self.a = a

Let's create an instance of this class.

>>> obj = A(5)    
>>> print obj.a
5                 #output ...

more info..

Not exactly, not exactly tim the enchanter

By : Javed Khan

I've been putting off writing about my experience with django form wizard for some time now. I came across this blog post by Kenneth Love which finally compelled me to write this down.

About Django Form Wizard:

Form Wizard can be handy when you have a huge form, and you want to make it less intimidating to the user by splitting it into multiple steps.

If you have glued multiple forms together with sessions or whatnot and it turned out to be a mess, you now what I'm talking about :)

Think surveys, checkouts, lengthy registrations etc.

The class ...

more info..
Topics : django forms wizard

The missing documentation for django.utils.datastructures

By : Thejaswi Puthraya


django.utils.datastructures is intentionally not documented by the django core devs because it is an internal API and is liable to change without any notice. This file is not governed by django's lenient backwards-compatible policy. You have been sufficiently warned!

With the note out of the way, let's look at the interesting datastructures in this file. You may ask why we should learn about those when we shouldn't be using them? Reading code is the best way of learning and this file has some beautiful code.

MergeDict is the first of the datastructures in the ...

more info..
Topics : django internals

Dissecting Phonegap's architecture

By : Thejaswi Puthraya

Apache Cordova is a open source cross-platform framework for building native mobile applications using HTML, CSS and JavaScript. It started off as Phonegap, a project of Nitobi Software before it was acquired by Adobe Systems. The code for the platform was donated to the Apache Software foundation and is currently being incubated as "Apache Cordova".

Phonegap is now a distribution of Apache Cordova (analogous to Ubuntu being a Linux distribution) brought to you by Adobe. Since Apache Cordova is licensed under the permissive Apache Software License, Adobe Phonegap may technically be integrated with proprietary software (though there's no evidence ...

more info..

Dropbox file upload handler for django

By : Thejaswi Puthraya

Dropbox announced new pro plans last week and some accounts have had their storage size doubled. Wouldn't it be wonderful if we could upload all our files to dropbox from our django webapp?

In this post, I write a custom file upload handler that will upload files from our application to dropbox.

Let us see how to use the custom file upload handler.

Install the Dropbox Python SDK before you setup your django app to handle the file uploads.

In your, add the following attributes (with the values filled):


# Optional values below

# The ...

more info..

Using Ubuntu cloud images in KVM

By : Thejaswi Puthraya

Quite a few of our clients are powered by Amazon EC2 or Rackspace and we use Ubuntu LTS releases for our servers. Canonical provides EC2 AMIs and Openstack images for all their releases. By using these JeOS images on the server as well as on the development platform reduces the dev/prod parity which we discussed in a previous post.

In this post, we'll see how to setup the Ubuntu cloud images in the local KVM hypervisor. Unlike the previous post, we'll use only the virt-manager to do the initial provisioning but you can be assured that there ...

more info..

Metaclass in Python

By : Akshar Raaj

In this post we will be talking about Metaclass in python. If you are reading some code which uses metaclass, you will probably come across __new__. If you are not familiar with what __new__ does, i suggest you first read about __new__.

You can read about __new__ in our last to last post

Throughout this post we will be talking about new style classes. Things might differ in old-style classes.

As we go, i will be trying everything on IPython and suggest you as well to try everything on IPython.

Let's see a little bit about normal Objects in ...

more info..

Libvirt and KVM

By : Thejaswi Puthraya

"But it works on my local setup!" We have heard or probably said this tens of times after something that we deployed to the production server breaks. After fire fighting for hours we learn that a particular package's version varies from the local setup. This is a fairly common problem that plagues every developer. Off late, quite a lot of interest and work is going into maximizing the dev/prod parity to prevent such problems.

Software like virtualenv help a great deal in compartmentalizing python dependencies but most web applications nowadays have to deal with loads of other dependencies ...

more info..

__new__() in python

By : Akshar Raaj

Lately I started looking into Django code and wish to write about internals of Django. I started with Django models and will be writing about it soon. For understanding how Django models work, I had to understand what metaclasses are and how metaclasses work. Metaclasses use method "__new__" and so I looked at what "__new__" does.

As __new__ is a static method, we will see a lttle bit about static methods and then __new__ in detail.

  1. Understanding static methods.

  2. Understanding method "__new__" of any class. We will see how to override method __new__ in a class.

Also, I will be ...

more info..

Understanding '*', '*args', '**' and '**kwargs'

By : Akshar Raaj

When i started learning Python, i was very confused regarding what args, kwargs, * and ** does. And i feel there are few like me who had this confusion and problem. With this post, i intend to reduce (hopefully i can eliminate) that confusion.

Throughout this post, i will be using ipython and i suggest you to try everything on ipython as well. We will intentionally make some mistakes along the way, so that we can understand this topic better.

Let's divide our work under five sections:

  1. Understanding what '*' does from inside a function call.
  2. Understanding what '*args' mean inside a ...

more info..
Topics : python args kwargs

Provisioning Made Easy With Chef

By : Saket Bhushan

Managing Servers and scaling at will is hard. The bigger web players have put in years of effort, brute-forcing at times and re-iterating their methodologies, have come up with the secret sauce which they use to keep their cloud cool. The article is meant to be introductory rather than comprehensive. Chef has a steep learning curve, and in this post I wish to simplify few of the basic concepts. So, instead of going to the Chef Docs, finding searching, reading and re-reading, few of the beginner concepts are put at one place, which will help you get started on your ...

more info..

Test Driven Development in Python

By : Anoop Thomas Mathew

We can either prevent bad things from happening or fix it, once it is detected.

It is your choice to select any of these methodology, while developing a software. You can either develop based on a test driven process or the recover from a fiasco with tests.

Test driven development, as the name suggests, is development based on tests. Tests for core features are written prior to the implementation for the expected output, and then necessary modules are written to satisfy the needs define the

Advantages of Test Driven Development

  • application is determined by using it
  • written minimal amount of ...

more info..

Deploying Django apps on Heroku

By : Shabda Raaj

Deploying Django apps on Heroku:

Read this first:

This is a great article by the Heroku. I am just filling in some more details and making this step-by-step.

  1. Get your Django project code.
  2. Create a virtualenv with a no-site-packages command ::

    virtualenv vent --no-site-packages

  3. Install Django, psycopg2 (postgres connector), gunicorn and any other required Django libraries.

  4. Confirm that you have all the required libraries and you can run your code locally using runserver.
  5. Create a requirement.txt by using ::

    pip freeze > requirements.txt
  6. Make sure you have a requirements.txt at the root ...

more info..
Topics : django

Developing android applications from command line

By : Thejaswi Puthraya

Here at Agiliq, we also develop cross-platform HTML5 mobile applications. Using Eclipse to create an android project (one time task) and edit html and javascript files for an android app is an overkill. Wouldn't it be great, if you could use your favourite text editor to edit html and js files and then fall back to the terminal to deploy the android app? We are going to see exactly this in the post.

First, let's install the android SDK starter package(I assume that you have installed JDK and ant). Head over here and install the SDK for ...

more info..
© Agiliq, 2009-2012