Django - CPF or CNPJ

0

Good afternoon, people.

As a way of learning, I'm creating a system in Django with a Customer registry.

Someone could help me in the logic so that in the register I can choose CPF or CNPJ.

My Models is currently like this:

class Cliente(models.Model):
    razao_social = models.CharField(max_length=80)
    nome_fantasia = models.CharField(max_length=80)
    cliente_classificacao = models.ForeignKey(ClienteClassificacao, null=False, blank=False, on_delete=models.PROTECT)
    cliente_situacao = models.ForeignKey(ClienteSituacao, null=False, blank=False, on_delete=models.PROTECT)
    cep = models.CharField(max_length=9)
    endereco = models.CharField(max_length=100)
    numero = models.CharField(max_length=6)
    bairro = models.CharField(max_length=100)
    municipio = models.CharField(max_length=50)
    estado = models.CharField(max_length=100)

    def __str__(self):
        return self.nome_fantasia

and my forms looks like this:

class ClienteForm(ModelForm):
    cep = BRZipCodeField(max_length=9)

    class Meta:
        model = Cliente
        fields = ['razao_social', 'nome_fantasia', 'cliente_classificacao', 'cliente_situacao',
                  'cep', 'endereco', 'numero', 'bairro', 'municipio', 'estado']

My intention is to select the client's classification at the time of registration and, depending on the classification, the form will already change the field mask.

Thankful

    
asked by anonymous 13.11.2018 / 20:21

0 answers