queryset extension with field from different model
Hi,
this is just a question to help me understand queryset usage a
little better.....
If I had two models, unrelated via foreignkey etc, but which shared a
common field, e.g.....
class modelOne(models.Model):
a = ....
b = ....
c = ....
class modelTwo(models.Model):
c = ....
d = ....
e = ....
how can I create a queryset pulling in features of both. That is, if I
had
myqueryset = modelOne.objects.all()
how can I append the d value from modelTwo (having worked out the
matching c values) to myqueryset?
For example, I'm assuming this is not the way I should be doing this:
myqueryset = modelOne.objects.all()
for item in myqueryset:
dvalue = <Code to grab d value from matching c value>
item.dvalue = dvalue
Any pointers for how I should be doing this? (noting that I have the
use case for ending up with a single queryset)
Many Thanks,
G
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home