Improvements in BRCPFField and BRCNPJField in localflavor.br.forms
|Reported by:||luizvital||Owned by:||Wiliam Alves de Souza|
|Severity:||Normal||Keywords:||localflavor, brcpffield, brcpnjfield, br, localflavor, localflavorsplit|
|Cc:||wiliamsouza83@…, semente+djangoproject@…, Sergio Oliveira, luiz.vital@…, philipe.rp@…, semente+django@…||Triage Stage:||Accepted|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||yes|
When using the fields
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
Falseto prevent unexpected behavior to the current users of this
return_format: a string to format the output, defaults to '%s.%s.%s-%s' in
In addition to these, I've changed the parent class of
CharField to take advantage of
Tests for these features included and fixed some errors in previous doctest that were expecting a unicode string.
Change History (17)
comment:7 Changed 8 years ago by
|Keywords:||brcpffield, brcpnjfield, br, localflavor → localflavor brcpffield, brcpnjfield, br, localflavor|
|Owner:||changed from nobody to Wiliam Alves de Souza|
|Status:||new → assigned|
|Triage Stage:||Unreviewed → Accepted|
comment:12 Changed 6 years ago by
|Patch needs improvement:||set|