Answer the question
In order to leave comments, you need to log in
How to access django proxy model method?
There is a user model:
class User(AbstractBaseUser, PermissionsMixin):
class Type(models.TextChoices):
default = 'default', 'Стандартный Пользователь'
vip = 'vip', 'Вип пользователь'
email = models.EmailField(_('email address'), unique=True)
phone = models.CharField(
verbose_name='Телефон', blank=False, default='', max_length=18)
is_active = models.BooleanField(default=True)
date_joined = models.DateTimeField(default=timezone.now)
type_user = models.CharField(
'Тип', choices=Type.choices, default=Type.default, max_length=15)
class DefaultUser(User):
objects = DefaultUserManager()
def test(self):
return 1
class Meta:
proxy = True
class VipUser(User):
objects = VipUserManager()
def test(self):
return 2
class Meta:
proxy = True
Answer the question
In order to leave comments, you need to log in
Anton , you cannot get an inheriting class from an inherited one. You can access the test method only from instances of the DefaultUser or VipUser class on a non-User
PS
Where have you seen someone do this?
class User(AbstractBaseUser, PermissionsMixin):
class Type(models.TextChoices):
default = 'default', 'Стандартный Пользователь'
vip = 'vip', 'Вип пользователь'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question