Edit Choice error in Django Model

0

I have the following model:

class Producto (models.Model):
    id = models.BigAutoField(primary_key = True)
    nombre = models.CharField(max_length = 32)
    estado_rev = models.IntegerField(choices = CHOICES_ESTADO_REV, default = CHOICES_ESTADO_REV[1][0])
    f_publi = models.DateTimeField(auto_now_add = True)
    f_act = models.DateTimeField(auto_now = True)
    descrip = models.TextField(max_length = 255)
    medidas = models.TextField(max_length = 255, null = True, blank = True)
    color = models.IntegerField(choices = CHOICES_COLOR, default = CHOICES_COLOR[0][1])
    marca = models.ForeignKey(Marca)
    categoria = models.ForeignKey(Categoria)
    perfil = models.ForeignKey(Perfil, related_name='productos', on_delete= models.CASCADE)
    p_venta = models.PositiveIntegerField()

The color field has this choice:

CHOICES_COLOR = (
    ('','Seleccionar'),
    (1,"Negro"),
    (2,"Rojo"),
    (3,"Naranja"),
    (4,"Amarillo"),
    (5,"Azul"),
    (6,"Rosa"),
    (7,"Beige"),
    (8,"Marron"),
    (9,"Gris"),
    (10,"Verde"),
    (11,"Morado"),
    (12,"Blanco"),
    (13,"Plateado"),
    (14,"Dorado"),
    (15,"Multicolor"),
)

When I do the migration in it runs perfectly, but I added the following value to the choice: (16,"Estampado") and it makes me do a new migration in which I get an error in the field color because "Select" is not a valid value.

Is there any way to skip this error or correct it?

    
asked by F Delgado 11.09.2018 в 11:03
source

0 answers