Preventing django from appending “_id” to a foreign key field

后端 未结 2 648
-上瘾入骨i
-上瘾入骨i 2021-02-02 08:26

In django, if I set a field in a model to a foreign key, \"_id\" is appended to the name of that field. How can this be prevented?

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-02 08:51

    You can set the field's db_column attribute to whatever you'd like.

提交回复
热议问题