2👍
✅
Proxy models are used to modify Python behaviour of a model by extending a model class. Database tables aren’t generated for proxy models. So you can’t use a proxy model for AUTH_USER_MODEL
. In fact, you can’t use a proxy model if you want a db table for that model.
To understand proxy models better, consider this:
class Badge(models.Model):
name = ...
color = ... # gold/silver
class GoldBadge(Badge)
class Meta:
proxy = True
def award(self, user):
# award a gold badge to user
class SilverBadge(Badge):
class Meta:
proxy = True
def award(self, user):
# award a silver badge to user
Tables are generated for only Badge
model whereas GoldBadge
and SilverBadge
are proxy models so no tables are generated for them. They are just extending the functionality (i.e. changing Python behaviour) of Badge
model.
See docs on proxy models
Source:stackexchange.com