﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
10895	Improvements in BRCPFField and BRCNPJField in localflavor.br.forms	luizvital	Wiliam Alves de Souza	"When using the fields `BRCPFField` and `BRCNPJField` in `django.contrib.localflavor.br.forms` I missed a uniform return format in the cleaned value of these fields, as they validate formatted and digits only inputs and the cleaned data preserves the same format as the entered value. If you're not enforcing a particular format with JavaScript, you may end up with a non standardized values on the database.

Ex.: For `BRCPFField `the values cleaned can be '999.999.999-99', '99999999999', '999999999-99', etc...

My suggestion is to keep the diversity of valid input formats, but provide a way to uniform the format of the cleaned value.

The implementation consists of adding two optional keyword arguments:

 * `always_return_formatted`: a boolean which indicates if the cleaned value must always be in a particular format, the default is `False` to prevent unexpected behavior to the current users of this `FormField` class.
 * `return_format`: a string to format the output, defaults to '%s.%s.%s-%s' in `BRCPFField`

In addition to these, I've changed the parent class of `BRCNPJField` from `Field` to `CharField` to take advantage of `max_length` and `min_length` validators.

Tests for these features included and fixed some errors in previous doctest that were expecting a unicode string. 
"	Bug	closed	contrib.localflavor	dev	Normal	invalid	localflavor, brcpffield, brcpnjfield, br, localflavor, localflavorsplit	wiliamsouza83@… semente+djangoproject@… Sergio Oliveira luiz.vital@… philipe.rp@… semente+django@…	Accepted	1	0	0	1	0	0
