One database table, one model, many behaviours: Proxy model
summary
Shows that Django proxy=True models reuse the same database table while giving different Python behaviors, demonstrated with Programmer/Doctor/JungleNut proxy classes. Uses a custom manager with a get_queryset filter to expose only specific roles, and override save to set type automatically. Applies to extending the base User and customizing the admin, and solves adding behavior to an existing production table without creating new tables, with working console examples and admin integration.
AI-written summary · about
chapters (5)
- 0:00Introduction
- 2:34Model inheritance in Django
- 9:51Proxy models explained
- 14:17Model managers for queries
- 20:56Proxy model use cases
related talks
24mThe Ins and Outs of Model Inheritance
30mRed User, Blue User, MyUser, auth.User
30mThe Wizardry of Metaprogramming
01h 06mEffective Django
25mMultitenant applications: how and why
31m"Notes on Over-Engineering: A Project Post-Mortem"
29mDatabase Sorcery 101 Ditch the Ancient SQL Scrolls for SQLModel
01h 10mIt's Pythons All The Way Down: Python Types & Metaclasses Made Simple
