Re: Password validation Error with Latin characters

2017-11-29 Thread Claude Paroz
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

Le jeudi 30 novembre 2017 02:39:31 UTC+1, Adrian Mansilla a écrit :
>
> 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.']
>
>

-- 
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+unsubscr...@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/41974e26-5baf-41bd-90c6-bd5232f2a5c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Password validation Error with Latin characters

2017-11-29 Thread Adrian Mansilla


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.']

-- 
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+unsubscr...@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/c6146f4a-e890-47c3-a6b4-e0d237d0073f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Adding generated common table expressions

2017-11-29 Thread matthew.pava
I would like to know what the status of this is (adding CTE functionality 
to Django).  It is supported by all current databases that Django supports.

On Friday, March 17, 2017 at 6:49:39 PM UTC-5, Tim Graham wrote:
>
> Hi, I don't know anything about CTE, but did you see this third-party 
> package? https://github.com/petrounias/django-cte-trees -- It seems to be 
> PostgreSQL only.
>
> I was going to write, "Considering that not all databases support CTE 
> (MySQL doesn't), a third-party app might be the way to go rather than 
> having it built-in to Django." -- however, then I noticed that supported is 
> added in MySQL 8 [0], so maybe any database differences could be abstracted 
> away with an appropriate API.
>
> I'll leave it to others to comment on the technical details of your 
> proposal. Meanwhile, if you have a chance to contribute smaller patches to 
> Django, I think it's helpful to start with smaller patches before tackling 
> something larger like this.
>
> [0] 
> http://mysqlserverteam.com/mysql-8-0-labs-recursive-common-table-expressions-in-mysql-ctes/
>
> On Friday, March 17, 2017 at 7:28:17 AM UTC-4, Ashley Waite wrote:
>>
>> Hey all,
>>
>>
>> I'd like to suggest adding Common Table Expression (CTE) query generation 
>> as a feature to Django.
>>
>> I've been working on a project that required manipulation of many records 
>> at once, and as with many ORMs found that this wasn't an ideal use-case in 
>> Django. As the rest of our code base and related projects are in Django, 
>> there was a strong preference to find a way to do it and keep to the same 
>> model-is-the-truth design.
>>
>> I first did this by writing some hackish functions using raw querysets 
>> and generating my own CTE based queries, but it lacked ideal flexibility 
>> and maintainability. So I've now written some modifications into my Django 
>> to do this in a more Django-esque way and think that this functionality 
>> would be beneficial within the project itself, but am unsure exactly where 
>> to start the conversation about that.
>>
>>
>> *Why generate CTE based queries from querysets?*
>>
>> By allowing querysets to be attached to each other, and setting 
>> appropriate WHERE clauses, arbitrary and nested SQL queries can be 
>> generated. Where the results of the queries are only necessary for the 
>> execution of following queries this saves a very substantial amount of time 
>> and database work. Once these features exist, other functionality can also 
>> transparently use these to generate more efficient queries (such as large 
>> IN clauses).
>>
>> This allows several powerful use cases I think Django would benefit from:
>>
>>
>> *Large 'IN' clauses*, can be implemented as CTEs reducing expensive 
>> lookups to a single CTE INNER JOIN. For sets of thousands to match from 
>> tables of millions of records this can be a very substantial gain.
>>
>>
>> *Composite 'IN' conditions,* where multiple fields must match and you're 
>> matching against a large set of condition rows. In my usage this was "where 
>> the md5/sha hashes match one of the million md5/sha tuples in my match 
>> set". This is simply a CTE JOIN with two clauses in the WHERE.
>>
>>
>> *Nested data creation*, where the parent doesn't yet exist. Django 
>> doesn't currently do this as the primary keys are needed, and this makes 
>> normalised data structures unappealing. Using INSERTs as CTEs that supply 
>> those keys to following statements means that entire nested data structures 
>> of new information can be recreated in the database at once, efficiently 
>> and atomically.
>>
>>
>> *Non-uniform UPDATE*s, such that a modified set of objects can all be 
>> updated with different data at the same time by utilising a CTE values 
>> statement JOINed to the UPDATE statement. As there's currently no way to do 
>> this kind of bulk update the alternative is to update each instance 
>> individually, and this doesn't scale well.
>>
>> These could also be used with aggregations and other calculated fields to 
>> create complex queries that aren't possible at the moment.
>>
>>
>> *What my PoC looks like*
>>
>> With another mildly hackish PoC that creates a VALUEs set from a 
>> dict/namedtuple which can be used to provide large input data, my present 
>> modified version syntax looks a bit like this (not perfect queries):
>>
>> class Hashes(models.Model):
>> md5 = models.UUIDField(verbose_name="MD5 hash (base16)", db_index=True)
>> sha2 = models.CharField(max_length=44, null=True, verbose_name="SHA256 
>> hash (base64)")
>>
>> # Mock QuerySet of values
>> q_mo = Hashes.as_literal(input_hashes).values("md5", "sha2")
>> # A big IN query
>> q_in = Hashes.objects.attach(q_mo).filter(md5=q_mo.ref("md5"))
>>
>> # Matched existing values with composite 'IN' (where md5 and sha2 match, or 
>> md5 matches and existing record lacks sha2)
>> q_ex = 
>> Hashes.objects.attach(q_mo).filter(md5=q_mo.ref("md5")).filter(Q(sha160=q_mo.ref("sha160"))
>>  |