On 27-7-2012 14:47, David wrote:

> I am using the above code to isolate any fields in self._meta.fields that 
> are foreign keys. I need to get data from these foreignkey relations to 
> other models.
> 
> Is this possible please?

Depends what you need to do with it. I'm doing something similar for my
JSONResponseMixin and recursively visit foreign keys. However, since
models are converted to dictionaries by this method, I just tack on the
result as a another dict, so for a city model you'd get:
{
    'name': 'Amsterdam',
    'country': { 'name': 'Netherlands', 'code': 'NL' }
}

The principle applies though, you can fetch the fields you want and tack
on the result on whatever object instance you want to tack it on that
you have access to. You can't however tack it on to classes, or at least
I'm not seeing an easy way to do that.

-- 
Melvyn Sopacua

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to