Returning data belonging to a model (FK)

2012-07-27 Thread David
Hi I am trying to abstract one of my applications. for f in self._meta.fields: print f if f.get_internal_type() == "ForeignKey": for o in f.related.parent_model.objects.all(): I am using the above code to isolate any fields in self._meta.fields tha

Re: Returning data belonging to a model (FK)

2012-07-27 Thread Victor Rocha
David, Django already comes with a built-in contenttypes application which does exactly what you trying to accomplish, i think. You should read the documentation: https://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/ On Friday, July 27, 2012 8:47:37 AM UTC-4, David wrote: > > Hi > >

Re: Returning data belonging to a model (FK)

2012-07-27 Thread David
Hi Victor I am using contenttypes already and am finding it hugely useful. I am trying to decouple the applications need to "know" the model that the contenttype has linked to. This way it should generically understand, interpret and perform functions on any given instance of an object regardl

Re: Returning data belonging to a model (FK)

2012-08-02 Thread Melvyn Sopacua
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 f