Can I change Django's auth_user.username field to be 100 chars long without breaking anything?

前端 未结 7 1492
眼角桃花
眼角桃花 2021-02-06 05:31

Before somebody marks this question as a duplicate of this question Can django\'s auth_user.username be varchar(75)? How could that be done? or other such questions on SO, pleas

7条回答
  •  伪装坚强ぢ
    2021-02-06 06:14

    For me, the code below works and is simple well.

    from django.contrib.auth.models import AbstractUser
    
    class MyUser(AbstractUser):
        ....
        # your custom fields
    
    MyUser._meta.get_field('username').max_length = 255  # or 100
    

    after you can run your migration

提交回复
热议问题