防止Django附加“ _id”到外键字段 [英] Preventing django from appending "_id" to a foreign key field

查看:96
本文介绍了防止Django附加“ _id”到外键字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在django中,如果我将模型中的字段设置为外键,则会在该字段的名称后附加 _ id 。如何防止这种情况?

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?

推荐答案

您可以设置字段的 db_column 属性设置为所需的任何值。

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

这篇关于防止Django附加“ _id”到外键字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆