Django的“article_set”来自哪里? [英] Where does 'article_set' come from in Django?

查看:644
本文介绍了Django的“article_set”来自哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用Django / Pinax应用程序(我确定我的问题不是Pinax特定的,这就是Pinax在主题标题中没有提到的原因),而且我正在设计整个框架的工作原理。现在,我必须写一个视图将数据传递给一个模板。我只在django手册中看到它:在手册中,ObjectName.objects.all()只是传递给render_to_response()。我的任务更复杂一些,所以我试图理解它是如何在pinax应用程序的配置文件中完成的,并且完全失败。

I am currently working on a Django/Pinax application (I'm sure my question is not Pinax-specific, that's why Pinax's not mentioned in the theme title), and I'm trying to figure out how the whole framework works. Right now, I have to write a view to pass data to a template. I've only seen it done in the django manual: In the manual, ObjectName.objects.all() is simply passed to render_to_response(). My task is somewhat more complicated, so I've tried to understand how it is done in a pinax application 'profiles', and failed completely.

所以,$ $ c> profile.html 模板文件有这样的一行:

So, profile.html template file has a line like this:

{% for article in other_user.article_set.all %}

'other_user'是传递给User类的一个实例views.py中的render_to_response()。好的,但是article_set不是它的类变量。我在应用程序代码的任何地方找不到article_set描述,但发现更多的事情看起来像是一样的调用方式:

'other_user' is an instance of the 'User' class passed to render_to_response() in views.py. Ok, but article_set is not its class variable. I've failed to find article_set description anywhere in the application code, but found more occurrences of something looking like the same form of call:

{% for bookmark_instance in other_user.saved_bookmarks.all.select_related %}

仅搜索Django文档在这个页面中,没有说明'article_set'是什么。

Searching Django docs only resulted in this page, not telling what 'article_set' exactly is.

什么是article_set?它在哪里定义,它是如何工作的?任何答案或只是文档链接非常感激。谢谢。

What is article_set? Where is it defined and how does it work? Any answers or just documentation links are strongly appreciated. Thank you.

推荐答案

请参阅关于后向关系的文档

还有一些例子

这篇关于Django的“article_set”来自哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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