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

前端 未结 7 1498
眼角桃花
眼角桃花 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:04

    You need to monkey-patch max-length in several places: model-field's description, form-field's description and max-length validators. Max-length validators are attached to form-fields as well as model-fields.

    Here is a code snippet, which will patch everything:

    https://gist.github.com/1143957 (tested with django 1.2 and 1.3)

    Update: Good news! Since django 1.5 you can override user model: Customizing the User model

提交回复
热议问题