I have a database and in one of the tables, a field should both be a primary and a foreign key. I am new to Django, and I couldn't find an example implementation.
I appreciate all the help, Didem
I tried looking the documentation or some example repos but didn't see anything
Since a primary key is always unique, the
ForeignKeyis then aOneToOneField[Django-doc], so:this is also how Django emulates inheritance. Indeed, with concrete inheritance it automatically adds a hidden primary key that is a
OneToOneFieldto the parent model.