views:

28

answers:

0

I have a GenericForeignKey in an inline on an admin page. Being a GenericFK there are 2 fields involved in it: The ContentType FK and the object_id integer field. The GenericFK can, of course, point to a variety of models and objects, some that have image fields and some that don't. My goal is to customize one of the widgets (it can be either, but I'm trying for the object_id one) such that if the object the GenericFK points to has an image, it displays a thumbnail of it.

The problem I'm running into is that I'm not aware of a way for a widget to know the value of another field when it is being drawn, since in order for the object_id or ContentType field's widget to find what object the GenericFK is pointing to, it needs both values. Is there a way to do this short of just going about this some other way completely, like using AJAX calls to pull in the thumbnails after the page loads?