0

Django username is not allow non-ascii, is there any way to overwrite username in modelform, then it accpets non-ascii charactor?

class RegiForm(ModelForm):
username = forms.CharField()
password=forms.CharField(label=(u'password'), widget=forms.PasswordInput(render_value=False))
password2=forms.CharField(label=(u'password2'), widget=forms.PasswordInput(render_value=False))

def clean_username(self): 
hln
  • 1,071
  • 4
  • 21
  • 37
  • What is the Traceback in your console? – Alex Parakhnevich Nov 18 '13 at 21:07
  • similar? [stack link](http://stackoverflow.com/questions/3656119/manage-py-syncdb-error-while-django-model-using-non-ascii-verbose-name) There's also information on the [django-link](https://docs.djangoproject.com/en/dev/ref/unicode/) if I'm following you correctly. – crownedzero Nov 18 '13 at 21:10
  • it throw a form.username.error in template. it won't validate non-ascii character as an username – hln Nov 18 '13 at 21:12
  • probably should cast a glance over this link - https://code.djangoproject.com/ticket/20694 – Alex Parakhnevich Nov 18 '13 at 21:31
  • you mean add this line in username validators=[ validators.RegexValidator(re.compile('^[\w.@+-]+$', flags=re.UNICODE), _('Enter a valid username.'), 'invalid'), it doen't help neither – hln Nov 18 '13 at 21:37

0 Answers0