Re: Accessing related fields.

2011-09-11 Thread Petey
Thank you Bruce and Daniel both anwsers really helped me. I really appreciate it :). -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/LkInATAnM28J. To post

Re: Accessing related fields.

2011-09-11 Thread Martin Tiršel
{{ p.source.all }} - is a list of source objects {{ p.source.all.0 }} - is the first item in the list of source objects (the same as p.source.all[0] in python) {{ p.source.all.0.some_attribute }} - you access some_attribute of the object source which is the first item in the list od source

Re: Accessing related fields.

2011-09-11 Thread Petey
Ooops I meant source ;) Firstly: {{ p.source.all.0 }} - < gets source name, only first element (as proper slice should work) but I still dont understand how to get all avaliable elements for each source in publisher Secondly: {{ p.source.url.all.0 }} < does not get URL from Source.url, I reall

Re: Accessing related fields.

2011-09-11 Thread Martin Tiršel
Hi, as Daniel wrote, the {{ p.source.all }} is a queryset you can access the same way as in {% for p in publisher.object_list %}. So you create a nested for loop. Martin On Sun, 11 Sep 2011 10:38:39 +0200, Petey wrote: And also how do I display more objets from that list? ;) Sorry for d

Re: Accessing related fields.

2011-09-11 Thread Petey
And also how do I display more objets from that list? ;) Sorry for double post -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/FAgvFRzJpdIJ. To post to thi

Re: Accessing related fields.

2011-09-11 Thread Daniel Roseman
Why would it be any different? You have the same relationship between Publisher and Category as you do between Publisher and Source, so just do the same thing again. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussio

Re: Accessing related fields.

2011-09-11 Thread Petey
That worked but how do I acces other field called "url" which is in Category model? -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/1VxdFnovRNEJ. To post t

Re: Accessing related fields.

2011-09-11 Thread Daniel Roseman
On Sunday, 11 September 2011 08:23:16 UTC+1, Petey wrote: > > The more time I spend with django, the more problems pop up :) > > I dont fully understand how to access related fields between models. (FK or > ManyToMany) > Code: > http://pastebin.com/qbciYqYw > > In code pasted below - {{p.souce.all

Re: accessing related fields of model

2009-03-19 Thread Malcolm Tredinnick
On Thu, 2009-03-19 at 13:20 -0700, adrian wrote: > > The doc gives this example for querying an Entry model which has a > foreign key field to a Blog model. > > e = Entry.objects.get(id=2) > e.blog = some_blog > > Fine. Now if I do it in a loop like this: > > e = Entry.objects.all() > for ent

Re: accessing related fields of model

2009-03-19 Thread Daniel Roseman
On Mar 19, 8:20 pm, adrian wrote: > The doc gives this example for querying an Entry model which has a > foreign key field to a Blog model. > > e = Entry.objects.get(id=2) > e.blog = some_blog > > Fine.  Now if I do it in a loop like this: > > e = Entry.objects.all() > for entry in e: >     entry

Re: accessing related fields of model

2009-03-19 Thread adrian
I found a serializer that can follow foreign key fields, which solves my problem. http://code.google.com/p/wadofstuff/wiki/DjangoFullSerializers But I would still like to understand if someone cares to answer! I think this should be in the documentation also. On Mar 19, 3:20 pm, adrian wrote