Can't save field with Djongo and AutoField

32 Views Asked by At

This Model generate id_num:

class Docahdl(models.Model):
    id_num = models.AutoField(primary_key=True)
    data_alter_doca = models.CharField(max_length=20)
    data_input = models.CharField(max_length=16)
    handling = models.IntegerField()
    doca_id = models.CharField(max_length=20)
    user_id = models.CharField(max_length=80)
    
    def __str__(self):
        return str(self.id_num)

But this won't generate id_num:

class SlaCD(models.Model):
    id_num = models.AutoField(primary_key=True)
    negocio = models.CharField(max_length=10)
    tipo_sla = models.CharField(max_length=50)
    data_inicio = models.DateTimeField()
    data_fim = models.DateTimeField()
    quantidade = models.FloatField()
    umd = models.CharField(max_length=10)
    
    def __str__(self):
        return str(self.id_num)

Can't have two or more AutoField using Djongo? When I create a instance and save Docahdl save the id_num on MongoDB, but SlaCD not.

0

There are 0 best solutions below