Hi together,

I'm trying to use select_related in a query, but it seems i'm doing
something wrong. I have googled, but not really found anything (Maybee
used the wrong keywords :/)

I've got a model that is related to another model, roughly like that:

class A(models.Model):
  a = models.CharField()

class B(models.Model):
  link = models.ForeignKey(A)

Now i want to query all entries in B along with the related models,
which would be the following (?)
objs = B.objects.select_related().all()
item = objs[0]

This produces one correct join-statement and populates all objects.
Now my problem: I need the keys of B / link.pk. Unfortunately item.pk,
item.id, item.link.pk, item.link.id gives me None as result. Do i need
to specify some other options, or is that just the default behaviour?
If so, is there a way to fill the ids anyhow? (I've got 30 rows with
~2 foreign-keys each and all of them get displayed, which hits the db
quite often.)
I'm using Django from the trunk.

Thanks for any help!
Daishy

-- 
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