[Answer]-How to set default values for django's User object?

1👍

After reading into the source code a bit, it seems like is_active is part of the AbstractBaseUser and not even as a field, here’s direct code excerpt:

class AbstractBaseUser(models.Model):
    # ...    
    is_active = True

It’s only later that is_active is turned into a field through another model called AbstractUser:

class AbstractUser(AbstractBaseUser, PermissionsMixin):
    # ...
    is_active = models.BooleanField(_('active'), default=True,
        help_text=_('Designates whether this user should be treated as '
                    'active. Unselect this instead of deleting accounts.'))

The User class itself defines almost nothing, really… This whole setup is sursprisingly convoluted, so I think there’s no simple way to do it (unless you want to change the source code, which isn’t recommended at all). using form_valid sounds like the best approach here.

👤yuvi

Leave a comment