Matt Seymour

I love the Django web framework I make use of it all the time. It is my goto web framework when I need to get something done quickly, or need something which I know will be expanded on over time.

For those of you not familiar Django is a python web framework which allows for the rapid development of web applications. Its core functionality is complete and can be easily extended. In the case the functionality you are looking for is not there you can rest assure someone has already built something that will help you achieve your end goals.

In particular I love these 5 things about Django. (If you are not yet a Django user I would highly recommend trying it out, I am sure you will love it too).

The Django admin

I cannot even begin to think how much time the Django admin has saved me over the years. If you have ever built the admin side of a web application you will know how mind numbingly boring it is. Just imagine that in a few lines of code you could have a fully functional administration panel for your application. Django gives you this ability as a built in option.

The Django admin works by creating the CRUD functionality of all your models used within your application.

Essentially it turns:

class Post(models.Model):
    title = models.CharField(max_length=200)
    slug = models.SlugField(max_length=200)
    text = models.TextField()
    timestamp = models.DateField()
    categories = models.ManyToManyField('Category')
    published = models.BooleanField(default=False)


Thought that was nice? It also gives you user management, user groups and change history by default.

Regex urls

As a developer you want to make your web application easy to develop, easy to use and pretty. A powerful feature within django is the ability to make powerful regex URLs that are pretty for the end user.

Within Django you specify your regex URL and bind a view function to this. As a result you can create easily readable URLs which can be mapped to various views and applications within your django project.

urlpatterns = patterns('',
        url(r'^$', 'myapp.views.home', name='home'),
        url(r'^contact/us/$', 'myapp.views.contact_us', name='contact_us'),

Here you will easily be able to see which urls we have available within our web application and which function is called as a result.

The named parameter name can also be used within the templating language to reverse generate the url.

For example:

<a href="{% url 'contact_us' %}">Contact</a>

Will generate the following code within the template:

<a href="/contact/us/">Contact</a>

What this does mean is that if the URL changes then all template urls will automatically be changed as a result.

Database migrations in core Django

Database migrations are a new feature in the Django core.

Migrations are Django’s way of propagating changes you make to your models (adding a field, deleting a model, etc.) into your database schema. They’re designed to be mostly automatic, but you’ll need to know when to make migrations, when to run them, and the common problems you might run into.

Migrations also have the added bonus of being able to revert the database change (though this does not undo any data manipulation which may have occurred). See Migrations in the Django documentation for more details.

You have NoSql options

By default Django makes use of a SQL based back-end supporting Postgres, Mysql, SQLite, Oracle and more. But what if you want a NoSQL option? Django can be used with NoSQL back-ends providing you options to work with MongoDB, Riak, and other NoSQL data-stores. The Django framework is very modular in its design and because of this different data back-ends can be used. I have used MongoEngine in several projects in the past and believe this is one of the better NoSQL data-store options to use with Django. The option of being able to use NoSQL means you as a developer can have a loosely attached schema which can change without the need for migrations.

Django community

An important factor when working with any technology is the community behind it. The community behind a technology are going to help you when you need help or advice.

The Django community is great for some many reasons.

  • Developer are willing to give their time freely to help other developers.
  • Sharing of code, just looking at will list over 2000 packages available for download.
  • Continuous development of the Django project.
  • Superb documentation of Django core.

In conclusion:

I am a massive fan of Django and whilst I have only listed a couple of reasons why I love Django there are many more. If you have thought about using Django I would strongly recommend trying out the simple tutorials found on the Django project website.

If you are a Django use, tweet me on twitter and tell me your favourite thing about Django.

Cool urls dont change