Skip to main content

Brazil specific Django helpers

Project description

https://img.shields.io/github/actions/workflow/status/leogregianin/django-br-utils/test.yml.svg?branch=main&style=for-the-badge https://img.shields.io/badge/Coverage-100%25-success?style=for-the-badge https://img.shields.io/pypi/v/django-br-utils.svg?style=for-the-badge

Funcionalidades para informações e dados do Brasil.

Por exemplo, pode incluir no forms ou nos models campos de códigos postais (CEP), números de CPF, número de CNPJ e número de processo judicial para validação automática.

Também pode incluir campos de seleção de estados, cidades com código IBGE, países com código IBGE e bancos registrados no Brasil.

Este pacote é inspirado no django-localflavor com melhorias e adição de novas informações específicas para o Brasil.

Requisitos

Python >= 3.8
Django >= 4.2

Veja todos os testes rodando em todas as versões Python e Django: https://github.com/leogregianin/django-br-utils/actions

Instalação

pip install django-br-utils

Adicione br_utils em INSTALLED_APPS no settings.py:

INSTALLED_APPS = (
   ...,
   'br_utils',
   ...,
)

Como utilizar nos models

from django.db import models
from django_br_utils.models import (
    BRCPFField,
    BRCNPJField,
    BRPostalCodeField,
    BRStateField,
    BRCityField
    CountryField,
    BRBankField,
)

class Cadastro(models.Model):
   nome = models.CharField(max_length=100)
   email = models.EmailField()
   cpf = BRCPFField()
   cnpj = BRCNPJField()
   cep = BRPostalCodeField()
   uf = BRStateField()
   cidade = BRCityField()
   pais = CountryField()
   banco = BRBankField()

Como utilizar nos forms

from django import forms
from django_br_utils.forms import (
    BRCPFField,
    BRCNPJField,
    BRPostalCodeField,
    BRStateChoiceField,
    BRCityChoiceField
    CountryChoiceField,
    BRBankChoiceField,
)

class CadastroForm(forms.Form):
    nome = forms.CharField(max_length=100)
    email = forms.EmailField()
    cpf = BRCPFField()
    cnpj = BRCNPJField()
    cep = BRPostalCodeField()
    uf = BRStateChoiceField()
    cidade = BRCityChoiceField()
    pais = CountryChoiceField()
    banco = BRBankChoiceField()

Contribuição

Contribuições são sempre bem vindas.

Sinta-se a vontade para abrir uma Issue para correções, dúvidas ou sugestões.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_br_utils-0.2.tar.gz (74.1 kB view details)

Uploaded Source

Built Distribution

django_br_utils-0.2-py3-none-any.whl (68.7 kB view details)

Uploaded Python 3

File details

Details for the file django_br_utils-0.2.tar.gz.

File metadata

  • Download URL: django_br_utils-0.2.tar.gz
  • Upload date:
  • Size: 74.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for django_br_utils-0.2.tar.gz
Algorithm Hash digest
SHA256 1d82b2e0d3af8363ab972efd80f41ef5915c7b43d6b51f5ab67f071976e8913f
MD5 b3a40bcc57e1ca89de78aefaf7b447dd
BLAKE2b-256 6776adb20e1440c58c34f1ff4fab2cba2e2b54b85f38acbd446cc85c27329c24

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_br_utils-0.2.tar.gz:

Publisher: release.yml on leogregianin/django-br-utils

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_br_utils-0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_br_utils-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2abc6a43b8429c46fdf5ff36436dd0178bcc411fd2dbbc4bc644e60991c286ff
MD5 3944aa2e49301a934a1f66e94a0ec57f
BLAKE2b-256 b3a2e2dccbe1d24f6dc777dbef5d7bf83f6713b9f286f9302f91a5f612ad9963

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_br_utils-0.2-py3-none-any.whl:

Publisher: release.yml on leogregianin/django-br-utils

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page