0

I started organizing my models in a package as specified here : https://docs.djangoproject.com/en/1.11/topics/db/models/#organizing-models-in-a-package

I'm using a legacy Oracle database

I also created a module containing some extensions/inheritances of the Model class, to facilitate creating multiple classes that contain repeated fields

This is my structure :

models/
    __init__.py
    geo_classes.py
    tables.py

The error is the following :

django.db.utils.DatabaseError: ORA-00904: "TABLE_NAME"."TABLECLASS_PTR_ID": invalid identifier

I couldn't find anything online about this PTR_ID it is trying to catch, maybe I missed something about extending base Models?


Files (only the important parts) :

geo_classes.py :

from django.db import models

class EsriTable(models.Model):
    objectid = models.BigIntegerField(unique=True, editable=False, verbose_name='OBJECTID')    

class TableClass(EsriTable):
    cod = models.BigIntegerField(primary_key=True)

    def __str__(self):
        return str(self.cod)

tables.py :

from .geo_classes import TableClass
from django.db import models

class MyClass(TableClass):
    #Fields
    name = models.CharField(max_length=50)
    #Keys
    #Relations

    class Meta:
        managed = False
        db_table = 'TABLE_NAME'
Mojimi
  • 2,561
  • 9
  • 52
  • 116

1 Answers1

1

You are using multi table inheritance. Each of your models is a separate table, including the base class. Django sets a pointer id to point to the parent table.

However, that's clearly not what you want. Neither of your base classes are actually tables on their own. So you need to use abstract inheritance: give both of those models their own inner Meta class, and set abstract = True.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895