Posted on by & filed under python.

When it comes to web development, there’s one thing almost as important as hard work: the appearance of hard work. While Django’s admin is very functional, it’s also pretty ugly. In this tutorial we’ll build a basic filtering UI and use Twitter’s Bootstrap and a select2 module to cure Django of its aesthetic curse, and look like we did something hard in the process.

Let’s start with a basic Django environment. Here’s my typical bootstrap:

Start the app:

Install some additional modules that we’ll use. You can omit ipython and readline, they’re more of a personal preference.

Be sure to add these to your INSTALLED_APPLICATIONS. django_select2 also requires a> entry. My currently looks like this:

django_select2 requires a url entry so make sure you put that in.

Add some classes to your to hold data. This is a basic tagging interface to tag a Person with any number of words.

After you syncdb, we can populate our database with some test data. I used the following snippets to generate data:

At this point we should have all the important chunks of our project set up. Now to wire in some select2 awesomeness into

Now all that’s left is to wire in views and forms. Here’s the code I use for

Here’s the code for overview.html:

Make sure all your urls are wired up, my looked like this:

We should now have something that looks like this:

Sample app

Tags: Bootstrap, Django, Python, select2, why-easy-install-use-pip-dude,

Comments are closed.