gpt4 book ai didi

python - Django Entry_Set 定义

转载 作者:行者123 更新时间:2023-12-01 06:11:30 26 4
gpt4 key购买 nike

我不明白《实用 Django 项目》第 87 页上的以下代码:

从 django.views.generic.list_detail 导入 o​​bject_list

def category_detail(request, slug):
category = get_object_or_404(Category, slug=slug)
return object_list(request, queryset=category.entry_set.all(),
extra_context={ 'category': category }))

entry_set 从哪里来?它在哪里定义的?谢谢。

最佳答案

这是created by the Entry model .

If a model has a ForeignKey, instances of the foreign-key model will have access to a Manager that returns all instances of the first model. By default, this Manager is named FOO_set, where FOO is the source model name, lowercased.

关于python - Django Entry_Set 定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5679408/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com