Question about validation and or documentation.
cgte opened this issue · comments
Currently i use django-countries with both raw data and clean data.
Unfortunately country codes do not seem to to be checked for validity.
it did the following to reproduce :
https://github.com/cgte/django-counrties-test/blob/main/sample/tests.py
how could we pre-validate data ? i wrote a sample cleaner function to sanitize input.
please let me know where it got things wrong and/or misunderstood.
I eventually found a point related to the issue :
https://github.com/cgte/django-countries/blob/main/django_countries/fields.py#L434
Maybe this is cause by not using modelForm in my import and/or test scripts ?
Model fields aren't implicitly validated when you save a model.
https://docs.djangoproject.com/en/5.0/ref/models/instances/#validating-objects
Note that full_clean() will not be called automatically when you call your model’s save() method. You’ll need to call it manually when you want to run one-step model validation for your own manually created models.