Password validation Error with Latin characters

77 views
Skip to first unread message

Adrian Mansilla

unread,
Nov 29, 2017, 8:39:31 PM11/29/17
to Django developers (Contributions to Django itself)

I am using the function 'validate_password (password, new_user)' and I have my settings configured in Spanish, the problem comes when the validate_password function raises an error with the word 'contraseña' and shows me this error:
ValidationError: [u'La contrase\xf1a es demasiado similar a la de nombre de usuario.']
I am using python 2.7 and Django 1.11.4

This is the traceback:

Traceback (most recent call last):
  File "/Users/adrianmansilla/Documents/sisgos/venv/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/Users/adrianmansilla/Documents/sisgos/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Users/adrianmansilla/Documents/sisgos/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/adrianmansilla/Documents/sisgos/venv/lib/python2.7/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/Users/adrianmansilla/Documents/sisgos/venv/lib/python2.7/site-packages/django/utils/decorators.py", line 185, in inner
    return func(*args, **kwargs)
  File "/Users/adrianmansilla/Documents/sisgos/sisgos/company/views.py", line 129, in new_user
    validate_password(password, new_user)
  File "/Users/adrianmansilla/Documents/sisgos/venv/lib/python2.7/site-packages/django/contrib/auth/password_validation.py", line 56, in validate_password
    raise ValidationError(errors)
ValidationError: [u'La contrase\xf1a es demasiado similar a la de nombre de usuario.']

Claude Paroz

unread,
Nov 30, 2017, 2:48:28 AM11/30/17
to Django developers (Contributions to Django itself)
Hi Adrian,

I don't see anything related to Django development in your post. Maybe this was more for the django-users mailing list?

Claude

Adrian Mansilla

unread,
Nov 30, 2017, 7:51:47 AM11/30/17
to Django developers (Contributions to Django itself)
Thanks for the reply.
I assumed that the error is in django because I do not send that message, Django sends it, the error is in:

django/contrib/auth/password_validation.py

And it's because my configuration is in Spanish.

Ramiro Morales

unread,
Nov 30, 2017, 8:26:53 AM11/30/17
to django-d...@googlegroups.com
Adrian,

I suspect:

1) Django is doing its work: It's checking the strenght and robustness of the password. It's detecting the password the user has chosen is too similar to their user name.

2) So, the fact the text shown has latin characters has nothng to do with the issue you are seeing.

3) The translation ('es') you are using isn't correct (https://github.com/django/django/blob/1a34dfcf797640d5d580d261694cb54e6f97c552/django/contrib/auth/locale/es/LC_MESSAGES/django.po#L258) and this might be what is misleading you.

   The original English text is

     The password is too similar to the %(verbose_name)s.
   
   and the translation should be:

     La contraseña es demasiado similar a {{ verbose_name }}

   verbose_name has the value "nombre de usuario" in this context.

   To confirm this you could temporarily set the languante to English (en-us) or to the es-ar (castellano as it's used in Argentina) and verify the original text/a more correct translation (https://github.com/django/django/blob/1a34dfcf797640d5d580d261694cb54e6f97c552/django/contrib/auth/locale/es_AR/LC_MESSAGES/django.po#L253)

As Claude said, Please open a thread in the django-users mailing lis i f you need to follow up this.


--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscribe@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/867d623d-7707-4f16-a779-293d8643b80f%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Ramiro Morales
@ramiromorales
Reply all
Reply to author
Forward
0 new messages