2021年1月21日星期四

composite key not displaying orrecyl on django admin

I have an intermediary model betwen "estados" e "listaflor", the flora2estado uses a composite key- and a primary key to trick django not to throw errors at me-.

When i click in one object at django admin i get this error:

MultipleObjectsReturned at /admin/accounts/flora2estado/99/change/  get() returned more than one Flora2Estado -- it returned 5!  

my models.py

class Estados(models.Model):      estado_id = models.AutoField(primary_key=True)      estado_nome = models.CharField(max_length=100, blank=True, null=True)        class Meta:          managed = False          db_table = 'estados'      class Familia(models.Model):      familia_id = models.AutoField(primary_key=True)      familia_nome = models.CharField(max_length=50, blank=True, null=True)      class Meta:          managed = False          db_table = 'familia'      class Flora2Estado(models.Model):      estado = models.OneToOneField(Estados, models.DO_NOTHING, )      especie_id = models.IntegerField()      flora2estado_id = models.AutoField( primary_key=True)         class Meta:          managed = False          db_table = 'flora2estado'          unique_together = (('estado', 'especie_id'),)  

admin.py

admin.site.register(Flora2Estado)  
https://stackoverflow.com/questions/65838001/composite-key-not-displaying-orrecyl-on-django-admin January 22, 2021 at 09:06AM

没有评论:

发表评论