Django 1.7中用户名较长 [英] Longer username in Django 1.7

查看:128
本文介绍了Django 1.7中用户名较长的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将django中的用户名的长度从30增加到80左右,我知道这可能是重复的问题,但是以前的答案不起作用,例如 https://kfalck.net/2010/12/30/longer-usernames-for-django



这是为Django 1.2。



有没有人尝试类似的黑客Django> 1.5
提前感谢

解决方案

自定义用户模型是一个巨大的变化,并不总是与应用程序兼容。我通过运行这个非常务实的移民来解决这个问题。注意这只能在数据库级别解决。



migrations.RunSQL(alter table auth_user alter column username type varchar(254);)


I want to increase the length of the username in django from 30 to around 80, I know it may be duplicate question but the previous answers are not working, for example https://kfalck.net/2010/12/30/longer-usernames-for-django

this is for Django 1.2.

Did anyone try similar hack for Django>1.5 Thanks in advance

解决方案

Custom User Models are a huge change to make and aren't always compatible with apps. I solved it by running this very pragmatic migration. Note this only solves it at the database level.

migrations.RunSQL("alter table auth_user alter column username type varchar(254);")

这篇关于Django 1.7中用户名较长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆