[Answer]-Modifying username field in user subclass

1👍

You can get the field by using the get_field method in the model’s meta class:

class User(AbstractUser):
    custom_field = models.BooleanField()
    ...

User._meta.get_field('username').validators = [list of validators,]
User._meta.get_field('username').help_text = "Help text"

Note that this will change the field’s settings for all subclasses and superclasses of User as well, as long as they have the field, because the field’s metadata is shared across all classes.

👤knbk

Leave a comment