Reputation: 4177
In my model i have
book_id PK
book_number as unique field
Now in my Author model i want to set up
book_number
as Foreign key not book_id
Is this possible
Upvotes: 1
Views: 466
Reputation: 87077
ForeignKey
refers to an entity by it's primary key, by database design. You should probably not do it although, you might be able to fake it within django by lieing within Model.Meta what the primary key is.
The right approach seems to me, is to make the book_number, the PK, if you are confident there aren't any repeats, and may be still retain the serial type for book_id.
Upvotes: 0