Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
一个 Card 模型有多个 Workouts 模型(ForeignKey to Card),每个 Workout 模型都有多个练习名称模型(ForeignKey to Workout)。我想访问模板中的练习名称值。哪个是最好的方法?
首先,请编辑您的问题以使用正确的“ForeignKey to X”,很难说出您的 FK 是什么。
但是要回答您的问题,foo_id是fooFK 字段的整数表示。
foo_id
foo
也就是说,print record.exercise将调用__unicode__()练习模型以获取要打印的表示,print record.exercise_id将打印实际的 FK id。
print record.exercise
__unicode__()
print record.exercise_id