我试图按照此处的描述进行操作:https://docs.djangoproject.com/en/dev/topics/db/optimization/#use-foreign-key-values-directly
我有一个这样的模型:
class Pizza(models.Model):
last_name = models.CharField(max_length=80, null=True, default=None)
baker = models.OneToOneField(User, to_field='username', parent_link=True, null=True,
db_column="django_username", default=None, db_constraint=False)
我有一个比萨实例,我想要存储在Pizza表中的实际用户名,而不是点击用户表。
答案 0 :(得分:1)
您始终可以通过附加" _id"来访问var referrer = HttpContext.Request.Headers["Referer"];
// referrer value is http://example.com/page-a.html if the above
// hyperlink is clicked on page-a.html. If the user types the
// new URL in the browser instead of clicking the hyperlink,
// HTTP referer will usually be null, depending on the browser implementation.
或ForeignKey
列的实际值。到字段名称
OneToOneField