Entries published on December 17, 2023
Don’t use class methods on Django models
This is part of a series of posts I’m doing as a sort of Python/Django Advent calendar, offering a small tip or piece of information each day from the first Sunday of Advent through Christmas Eve. See the first post for an introduction.
Being methodical about Python
Python classes support three basic types of methods:
- Instance methods, which are what you get by default when writing a
def
statement inside a class body. These are called from an instance of the model, and Python will ensure that the instance is passed as the first positional argument (conventionally namedself
) …