Override formfield method on Brazilian Model Fields #489
Open
Description
Hello.
The Model Fields on Brazilian localflavor does not override the method formfield
. By instance, the BRPostalCodeField is defined as:
class BRPostalCodeField(CharField):
"""
A model field for the brazilian zip code
.. versionadded:: 2.2
"""
description = _("Postal Code")
def __init__(self, *args, **kwargs):
kwargs['max_length'] = 9
super().__init__(*args, **kwargs)
self.validators.append(validators.BRPostalCodeValidator())
But in other countries this method was overrided. As instance, this is the Canadian PostalCode:
class CAPostalCodeField(CharField):
"""
A model field that stores the Canadian Postal code in the database.
Forms represent it as a :class:`~localflavor.ca.forms.CAPostalCodeField` field.
.. versionadded:: 4.0
"""
description = _("Canadian Postal Code")
def __init__(self, *args, **kwargs):
kwargs['max_length'] = 7
super().__init__(*args, **kwargs)
def formfield(self, **kwargs):
defaults = {'form_class': CAPostalCodeFormField}
defaults.update(kwargs)
return super().formfield(**defaults)
I made this change on Brazilian fields and it has passed all the tests. Do I need to write more tests or I can already submit a pull request?
Metadata
Assignees
Labels
No labels