django 中的 Model.id 和 Model.pk 有什么区别? [英] What's the difference between Model.id and Model.pk in django?

查看:19
本文介绍了django 中的 Model.id 和 Model.pk 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到django文件有时两者都用?它们相同吗?有什么区别,参考在哪里?我只看到 pk 的文档.

I saw the django documents use both sometimes? Are they identical? What's the difference and where is the reference? I only see documentation of pk.

顺便说一句,django 参考是否涵盖了其类的所有方法?

BTW, does django reference cover all the methods of its classes?

推荐答案

pk包含模型主键的值.id 是默认创建为主键的字段名称 如果没有明确指定.

pk is the attribute that contains the value of the primary key for the model. id is the name of the field created as a primary key by default if none is explicitly specified.

这篇关于django 中的 Model.id 和 Model.pk 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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