django.auth manipulate model fields/allow space in usernames

僤鯓⒐⒋嵵緔 提交于 2019-12-06 13:28:43

You can always override the UserCreationForm from contrib.auth.forms to implement a different field for username and provide your own validation. Just inherit the form and add your own username field, or override it in the __init__ of the class.

Nicolas Ardison

Maybe you would like to use validate_slug:

A RegexValidator instance that ensures a value consists of only letters, numbers, underscores or hyphens

For the user name: Override the UserCreationForm (django.contrib.auth.forms) to modify the regex parameter for the field to allow for spaces. No changes to the model are necessary.

For the email: http://djangosnippets.org/snippets/74/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!