django / django-localflavor

Country-specific Django helpers, formerly of contrib fame

Home Page:https://django-localflavor.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Model fields to brazillian documents

andrelramos opened this issue · comments

I'm working on a system that needs some specific brazilian fields. Some of them already has in br form fields but a have many model forms that needs this fields and it would be nice if they were created as model fields.

The fields are:

  • Brazilian documents (CPF and CNPJ)
  • Brazilian Telephone and Cell Phone format
  • Brazilian Zip Code

In 2015 i was started a PR with code to solve it (#188) but it was denied, so i'm creating this issue to check the idea.

It's fine by me. I don't know what the PR was turned down last time. I'll review this PR when you make it.

It's best to extract the validation into a separate validator and use this validator for the form and the model. You can look at some the example models already included in localflavor to see how it's done (e.g. the IBAN fields).

If you're not sure about something, just make a 'work in progress' PR and we can discuss things on the PR. Thanks!

@benkonrath it's done! can you take a look in PR #341?

Fixed in 9d47350.