Cache the generic relation field of all the objects 
in the queryset, using larger bulk queries ahead of time.
 
Improved from original by Daniel Roseman:
http://blog.roseman.org.uk/2010/02/22/django-patterns-part-4-forwards-generic-relations/

and

justinfx's gist cache_generics.py :
https://gist.github.com/justinfx/3095246#file-cache_generics-py

Supports customized object_id_field and GenericForeignKey name.