problem with uppercase in django

0

I have an uppercase problem in django, in the following code, it works in the first form and in the last form, but in the intermediary forms it does not translate the letters sent to the bank in capitals ...

models.py

class Requerente(models.Model):
NACIONALIDADE = (
    ('BRASILEIRO', 'BRASILEIRO'),
    ('BRASILEIRA', 'BRASILEIRA'),
    ('ESTRANGEIRO', 'ESTRANGEIRO'),
    ('ESTRANGEIRA', 'ESTRANGEIRA'),
    )
ESTADO_CIVIL = (
    ('CASADO', 'CASADO'),
    ('CASADA', 'CASADA'),
    ('SOLTEIRO', 'SOLTEIRO'),
    ('SOLTEIRA', 'SOLTEIRA'),
    ('DIVORCIADO', 'DIVORCIADO'),
    ('DIVORCIADA', 'DIVORCIADA'),
    ('VIÚVO', 'VIÚVO'),
    ('VIÚVA', 'VIÚVA'),
)
REGIME = (
    ('COMUNHAO DE BENS', 'COMUNHAO DE BENS'),
    ('COMUNHAO PARCIAL DE BENS', 'COMUNHAO PARCIAL DE BENS'),
    ('SEPARAÇÃO DE BENS', 'SEPARACAO DE BENS'),
    )
nome = models.CharField(max_length=100)
nacionalidade = models.CharField(choices=NACIONALIDADE, max_length=50, null=True)
estado_civil = models.CharField(u'estado civil', max_length=50, choices=ESTADO_CIVIL, null=True)
nubente = models.CharField(max_length=100, null=True)
regime = models.CharField(u'regime', max_length=50, choices=REGIME, blank=True, null=True)
profissao = models.CharField(max_length=50, null=True)
rg = models.CharField(max_length=100, null=True)
orgao = models.CharField(max_length=50, null=True)
cpf = models.CharField(max_length=14, )
logradouro = models.ForeignKey(Logradouro, verbose_name=u'Rua, Av.')
numero = models.CharField(max_length=50, )
bairro = models.ForeignKey(Bairro, )
cidade = models.ForeignKey(Cidade)
telefone = models.CharField(max_length=20, blank=True, null=True)
celular =  models.CharField(max_length=20, blank=True, null=True)

def __unicode__(self):
    return self.nome
def save(self, force_insert=False, force_update=False):
    self.nome = self.nome.upper()
    super(Requerente, self).save(force_insert, force_update)

def save(self, force_insert=False, force_update=False):
    self.nubente = self.nubente.upper()
    super(Requerente, self).save(force_insert, force_update)

def save(self, force_insert=False, force_update=False):
    self.profissao = self.profissao.upper()
    super(Requerente, self).save(force_insert, force_update)

def save(self, force_insert=False, force_update=False):
    self.orgao = self.orgao.upper()
    super(Requerente, self).save(force_insert, force_update)
    
asked by anonymous 26.11.2017 / 00:16

1 answer

1

Why do not you just try to use a save and then treat those fields in this save?

Here is a possible solution, using a single save to handle the fields:

def save(self, *args, **kwargs):
    self.nubente = self.nubente.upper()
    self.profissao = self.profissao.upper()
    self.orgao = self.orgao.upper()

    super(Requerente,self).save(*args,**kwargs)

Put this single save in your Model and try to run again.

    
27.11.2017 / 13:47