With these Django ORM models:
class A(Model):
pass
class B(A):
pass
The table for B
in the resulting schema contains the field:
"a_ptr_id" integer PRIMARY KEY
Just for the sake of better understanding Django's design choices - It there any rationale documentation that mentions what "ptr" signifies?
My only guess is that it's an abbreviation for "pointer", but that seems pretty dumb since essentially any field with a foreign key constraint conceptually resembles a pointer.
ORM stands for Object Relational Mapper. The main goal of ORM is to send data between a database and models in an application. It maps a relation between the database and a model. So, ORM maps object attributes to fields of a table.
_ is usually a macro/function from gettext, it means the argument is a localized string.
It does stand for "pointer", but it's only used specifically for model inheritance in order to point to the parent model. Normal FKs only get "_id".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With