Hello list, I have a question. Take a look to the next models.
----------------------------
class MyDoc(models.Model):
    code = models.BigIntegerField()

class Myline(models.mode):
   fk_myDoc = models.ForeignKey(MyDoc)
---------------------------------------

In my view I do something like

myPaginator = Paginator(MyDoc.objects.filter(codigo=1), 10)
myDocs = myPaginator.page(page_number)

This return all the Docs with a code=1, but I too want to return all
the objects with the type "MyLine" associated to the results of this
query.

I try to do something like
--------------------
for i in range(len(myDocs.object_list))
myDocs.object_list[i].append(Myline.objects.filter(fk_myDoc=myDocs.object_list[i].id))
-------------
but don't work

I know that I can do 2 queries and return two list, one with the myDoc
list and other with the myLine list, but in that case in my template I
must to do something like

{% for myDoc im MyDocs.object.list %}
    {% for myline in Mylines %}
       {%if myDoc.id == myline.fk_myDoc %}
       ..................
       {% endif %}
    {% endfor %}
{% endfor %}

I don't want to do this, because I think a big "for" inside a big
"for" is innecessary.

Somebody have an idea??
Thanks for read, and sorry for my bad english.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to