Question

I have a bunch of objects of Model A (which really aren't important..), and i have a model B, located in another app.

Model B refers to other objects as such:

content_object  = generic.GenericForeignKey('content_type', 'object_id')

I'm only interested in the objects that hold references to types of Model A. Would it be possible to (somehow) use the template 'backwards'-functionality to retrieve them?

i've tried:

 {% for a in objectA.objectB_set.all %}
 and so on..

But it doesn't seem to work with 'generics'..?

Was it helpful?

Solution

It's not a real relationship, so objectA doesn't know anything about the B objects. You need to define a GenericRelation to ModelA to point back to B.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top