dstufft/django-activity-stream — comment on commit 8d1556726a99457261d94e6b4b58b3ff5a9673bc
File:  line 0
By dstufft:

I *think* this stems from the fact that related_name is normally set on a ForeignKey, and the related_name is the name on the model that is being related too.

However with GenericForeignKey's there is no automatic related attribute like on regular ForeignKeys. What you can do, and what this bit of code adds, is an explicit related attribute that is a instance of GenericRelation. However GenericRelation subclasses from Many2Many and thus has a related_name. In this case the related_name (the actions_with_blah_blah_as_blah) is actually more like related_related_name.

Going from the error messages I got as I tried different things I think that by default the related_related_name is set to whatever the GFK is called on the Parent model. However Action has 3 GFK's with many models having a reverse relation to it. This triggers the code that prevents setting the same related_name more than once on a model to kick in (in normal cases a related_name cannot point to more than one kind of model, but with GFK it can). The fix to that issue, as you can see from the code, is to generate a related_name. However GenericRelation's implementation of contribute_to_related is a noop statement (which matches the idea that the "related_name" in this case is actually the GFK).