Django querysets are really powerful. They can often be used to reduce expensive object iterations down to the database level. Let's take the following models and figure out which product has the least in stock.
from django.db import models
class Product(models.Model):
inventory = models.IntegerField()
class Package(models.Model):
items = models.ManyToMany(Product)
class Or...

A problem that many applications (hopefully) eventually run into is scalability. In a project I'm working on, we have a django management command that makes a time consuming API call to update a model. Let's take a look at the original code:
class Command(BaseCommand):
help = 'Create Shipping labels for upcoming shipments'
def handle(self, *args, **options):
start = datet...

A problem I recently ran into was allowing for multiple themes to be used on the same project. I decided to set a django setting called BRAND in order to control the theme through separate css files.
For this example, we will assume that your static directory has sub-directories for each brand, with a file site.css in each.
Now, in order to inject our brand setting into the context, we need...

As your Django app grows larger, your test suite starts piling up. In a project I was working on we had a test suite of 375 tests. Today I'll explain how I reduced the run time of that suite from 350+ seconds to 20 seconds.
1. Mock, mock, mock!
A HUGE bottleneck of our tests was in the billing logic. We had many tests that were actually hitting billing APIs (on test accounts of course, but s...

Before turning to a django package for a new feature, it's sometimes a good idea to take a step back and look at how difficult it would actually be to do it yourself. Sometimes its easier to implement yourself rather than install a package for something simple. I noticed this with gravatar.
Gravatar is a service for globally recognized avatars. Many times this is used in sites so that we don't ...

Recently I have been playing around with decorators in Python. Decorators are a really cool feature that allows you to add functionality to any function with a simple @decorator tag. It is very nice for injecting functionality to many functions that do similar things.
A place where this can be applied effectively is in Django views. This past weekend I was at a hackathon working with a fairly s...

I designed drf-generators to allow you (the developer) to spend less time worrying about views and serializers and more time creating rock-solid data models for your application.
If you know a bit about Django, you can create a basic API in minutes. This tutorial will walk you through creating a complete API using the Django rest framework and drf-generators to jump-start your development.
...

Today I was working to continue to improve my website and came across some really helpful stuff to improve the Django admin. By default, the django admin has a really simple interface for managing objects in your database. For example, the page for managing my Pages looks like this
This works and is much nicer than having to build my own admin, but there is a lot more power hidden in Django...

I have recently moved away from PHP and begun working with more all-purpose languages, Python being the main one. While experimenting with this new language, I rewrote my blog to use the Python web framework Django. Django 1.7 with Python 3.x is not supported by default on Dreamhost's shared servers, so here is how I installed my own custom version of Python to deploy my app.
In this tutorial I...

Its late, and I can't fall asleep, so I'm coding!The other day I started playing around with python some more and took a look at gtk and webkit. GTK is a gui thing (Idk what else to call it) for Python, like Swing is to Java. It comes installed on most linux systems and is pretty nice. Webkit is a nice little library for interfacing wiht websitesWhat so these two things combined create? A browser!...