Hi! Is it possible to access the foreignkey ID value of model? I do not want Django ORM to try to make query because it fails in this case. I have exact same problem as http://groups.google.com/group/django-users/browse_thread/thread/d24f2a502da3171c?pli=1 (though I'm not using admin, I have list view of my own)
I will use the same example: Host name = CharField Account name = CharField host = ForeignKey(Host, related_name='accounts') I have list of "Host" where I need to also list on each item a list of accounts. Now if I could access the raw "Account.host" foreignkey ID I could do this in two queries: hosts = list(Host.objects.all()) accounts = list(Account.objects.filter(host__in=hosts)) for h in hosts: h.account_list = [a for a in accounts if a.host_id == h.id] # NOTICE: THIS is not possible! I cannot access the foreignkey host_id : ( -- 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.