Skip to content

Instantly share code, notes, and snippets.

Where people struggle learning Django

Over the last 3 years or so I've helped a bunch of companies, small and large, switch to Django. As part of that, I've done a lot of teaching Django (and Python) to people new to the platform (and language). I'd estimate I've trained something around 200-250 people so far. These aren't people new to programming — indeed, almost all of them are were currently employed as software developers — but they were new to Python, or to Django, or to web development, or all three.

In doing so, I've observed some patterns about what works and what doesn't. Many (most) of the failings have been my own pedagogical failings, but as I've honed my coursework and my skill I'm seeing, time and again, certain ways that Django makes itself difficult to certain groups of users.

This document is my attempt at organizing some notes around what ways different groups struggle. It's not particularly actionable — I'm not making any arguments about what Django should or shouldn't do (at least

"I feel like I belong on this team."
"On this team, I can voice a contrary opinion without fear of negative consequences."
"On this team, perspectives like mine are included in decision making."
"On this team, administrative or clerical tasks that don’t have a specific owner are fairly divided."
"People on this team accept others who are different."
"It is easy to ask other members of this team for help."
"On this team, messengers are not punished when they deliver news of failures or other bad news."
"On this team, responsibilities are shared."
"On this team, cross-functional collaboration is encouraged and rewarded."
"On this team, failure causes inquiry."
"""
Take 2 - trying to minimize jump stitches
Stitch a row \ / \ /, then back
"""
import itertools
import pyembroidery as em
from collections import namedtuple
import click
import pyembroidery as em
pattern = em.EmbPattern()
# units are in 1/10mm
# max size in DST is 12mm so if we go bigger need to fuck with max_stitch
SIZE = 32
# start with a stitch at the origin to get the needle down (see the docs)
pattern.stitch_abs(0, 0)
@jacobian
jacobian / unicorn-socketserver.py
Created October 7, 2009 13:45
A simple preforking echo server using SocketServer.
"""
Simple forking echo server built with Python's SocketServer library. A more
Pythonic version of http://gist.github.com/203520, which itself was inspired
by http://tomayko.com/writings/unicorn-is-unix.
"""
import os
import SocketServer
class EchoHandler(SocketServer.StreamRequestHandler):
# https://stackoverflow.com/questions/53139643/django-postgres-array-field-count-number-of-overlaps
# !!! DOESN'T WORK but might with some more poking?
class Article(models.Model):
keywords = ArrayField(models.CharField(max_length=100))
def __str__(self):
return f"<Article {self.id} keywords={self.keywords}>"
import logging
l = logging.getLogger('django.db.backends')
l.setLevel(logging.DEBUG)
l.addHandler(logging.StreamHandler())
@jacobian
jacobian / check_postgres_replication.py
Created December 16, 2010 20:13
Nagios plugin to check PostgreSQL 9 streaming replication lag.
#!/usr/bin/env python
"""
Nagios plugin to check PostgreSQL 9 streaming replication lag.
Requires psycopg2 and nagiosplugin (both installable with pip/easy_install).
MIT licensed:
Copyright (c) 2010 Jacob Kaplan-Moss. All rights reserved.
import sys
import collections
import gridfs
import io
import psycopg2
import pymongo
import random
import time
# For fairness use the same chunk size - 512k.
web: gunicorn -w4 -b0.0.0.0:$PORT app:app