Limit the entries in the models.ForeignKey ()

0

Is it possible to limit the entries in models.ForeignKey () to an exact amount?

I have a model called a Card that belongs to a Profile, I want each profile to have a maximum of 2 cards.

class Tarjeta(models.Model):
    perfil = models.OneToOneField(Perfil,on_delete=models.CASCADE) #limitado a 2
    email = models.CharField(max_length = 255)
    titular = models.CharField(max_length = 20)
    direccion1 = models.CharField(max_length = 100)
    direccion2 = models.CharField(max_length = 100)
    ciudad = models.CharField(max_length = 50)
    pais = models.CharField(max_length = 2)
    telefono = models.CharField(max_length = 20)
    
asked by F Delgado 22.03.2018 в 17:47
source

0 answers