Django and CircleCI 2.0

Most of the time, deployment sucks. Using a continuous integration app can help automate your deployments so you can focus on writing code and buildings things. In this post I’ll show you how to set up a basic Django project with CircleCI so that publishing your code is as simple as pushing to GitHub.

Django access mixin for active users only

As of Django 1.9, there are a number of new permission mixins you can use with your views to make access control easier. One that isn’t included by default is a mixin allowing you to only permit users who have activated their account (user.is_active = True)

The Missing Manager for Django Models with GFK Relationships

Save yourself writing the same queries time and time again by creating a simple model manager with common queries for your generic foreign keys

Uploading and validating an image from an URL with Django

This post outlines a simple Django app that allows the user to upload an image via an URL while making sure the image file is valid.

Understanding, setting up, accessing and serving media files and static files in Django

One of my most popular Stackoverflow answers is to a question regarding the confusion between static and media files in Django. This post elaborates on that theme.

An Updated General Django Project (>= 1.5) Structure or Folder Layout

In a previous post I outlined a sane folder structure for a new Django project. Since then Django 1.5 (and 1.6) has been released along with an updated default folder structure. This post goes through some further tips on keeping your django project layout sensible.

A Custom Cropping Engine With sorl-thumbnail

Sorl-thumbnail has a sensible crop function in the default engine, but sometimes you need a little more control over the results. This post provides a custom cropping PIL engine that can be used to return specific, i.e. from (x1, y1) to (x2, y2), cropped thumbnails

Automatically generating admin URLs for your objects

It’s very easy to generate URLs to your django models using get_absolute_url(), but you can also use this pattern to just as easily create URLs to the admin page for your django models too. This post shows you how to make a get_admin_url() model method that generates links to give you quick access to your admin.