views:

37

answers:

2

Hello!

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 trying to figure out how the whole framowork works. Right now I have to write a view to pass data to a tempate. I've only seen it done in the django manual: there ObjectName.objects.all() is simply passed to render_to_response(). My task is somewhat more complicated, so I've tryed to understand how it is done in a pinax application 'profiles', and failed completely.

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

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

'other_user' is an instance of the 'User' class passed to render_to_responce() 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 occurences of something looking like the same form of call:

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

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

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

A: 

It's an artificial field created by a ForeignKey or ManyToManyField from the Article model.

Ignacio Vazquez-Abrams
+2  A: 

See the documentation on following the "backward" relations.

There are also some examples.

Ludwik Trammer