You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello.
The Model Fields on Brazilian localflavor does not override the method formfield. By instance, the BRPostalCodeField is defined as:
classBRPostalCodeField(CharField):
""" A model field for the brazilian zip code .. versionadded:: 2.2 """description=_("Postal Code")
def__init__(self, *args, **kwargs):
kwargs['max_length'] =9super().__init__(*args, **kwargs)
self.validators.append(validators.BRPostalCodeValidator())
But in other countries this method was overrided. As instance, this is the Canadian PostalCode:
classCAPostalCodeField(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'] =7super().__init__(*args, **kwargs)
defformfield(self, **kwargs):
defaults= {'form_class': CAPostalCodeFormField}
defaults.update(kwargs)
returnsuper().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?
The text was updated successfully, but these errors were encountered:
Thanks, @claudep !
I wrote 3 tests and altered one more. They fail with the current code but pass with my commits. I also added max_length and min_length validatiosn to the forms.BRZipCodeFIeld, so I could write it a test case similar to BRCPFFIeld and BRCNPJField. Finnaly, I removed the formfield override I made to BRStateField because it doesn't changed anything on the field behaviour. In future, it would be possible to enhance this field and, maybe, this override would be valuable. I will send all change as a Pull Request.
Hello.
The Model Fields on Brazilian localflavor does not override the method
formfield
. By instance, the BRPostalCodeField is defined as:But in other countries this method was overrided. As instance, this is the Canadian PostalCode:
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?
The text was updated successfully, but these errors were encountered: