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

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

问题描述

有时候我看到django文件有用吗?是否相同?有什么区别,参考在哪里?我只看到pk的文件。



BTW,django引用覆盖了所有类的方法?

解决方案

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


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

BTW, does django reference cover all the methods of it's classes?

解决方案

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天全站免登陆