'Django error while use when using inherit models
I have 2 models that affect 2 tables in my database, Gen_Persona and Ven_Vendedor.
The Ven_Vendedor table has the Gen_Persona primary key as its primary key.
I have investigated and managed to make the representation through abstract models, however, when I try to make a query I get the following error:
django.db.utils.ProgrammingError: column vendedor.gen_persona_ptr_id does not exist
LINE 1: ...M "ven"."vendedor" INNER JOIN "gen"."persona" ON ("ven"."ven...
I understand that the "ptr_id" refers to a pointer, but since I'm new to Django, I don't understand what change I should make.
I hope you can give me feedback on it.
Model Gen_Persona:
class Gen_Persona(models.Model):
prs_id = models.BigAutoField(primary_key=True,db_column='prs_id')
prs_identificacion = models.CharField(max_length=16)
prs_nombres = models.CharField(max_length=128)
prs_apellidos = models.CharField(max_length=128)
prs_razonsocial = models.CharField(max_length=256)
prs_fechanac = models.DateField(blank=True, null=True)
prs_email = models.CharField(max_length=64, blank=True, null=True)
prs_telef1 = models.CharField(max_length=16, blank=True, null=True)
prs_numtlf2 = models.CharField(max_length=16, blank=True, null=True)
prs_numcel = models.CharField(max_length=16, blank=True, null=True)
prs_img = models.CharField(max_length=256, blank=True, null=True)
prs_dirprinc = models.CharField(max_length=128, blank=True, null=True)
prs_dirsecun = models.CharField(max_length=128, blank=True, null=True)
prs_dirnum = models.CharField(max_length=32, blank=True, null=True)
emp_id = models.ForeignKey(Adm_Empresa, models.DO_NOTHING, verbose_name=Adm_Empresa._meta.verbose_name)
prs_estado = models.SmallIntegerField(default=True)
tid_id = models.BigIntegerField()
class Meta:
verbose_name='Persona'
managed = False
db_table = 'gen\".\"persona'
unique_together = (('prs_id', 'emp_id'),)
Model Ven_Vendedor :
class Ven_Vendedor(Gen_Persona):
prs_id_ven = models.OneToOneField(Gen_Persona, models.DO_NOTHING, db_column='prs_id_ven',related_name='fk_genpersona_venvendedor')
ven_codigov = models.CharField(max_length=32,verbose_name='Código')
ven_comision = models.DecimalField(max_digits=12, decimal_places=4,verbose_name="Comisión")
emp = models.BigIntegerField()
ven_estado = models.SmallIntegerField(default=True)
class Meta:
managed = False
verbose_name = 'Vendedor'
db_table = 'ven\".\"vendedor'
unique_together = (('prs_id_ven'),('emp'))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
