In my model i have
book_id PK
boo开发者_运维技巧k_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
to_field
.
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.
精彩评论