How to make entry.category to be instance of CategoryProxy? See code for details:
class Category(models.Model): pass
class Entry(models.Model):
category
Adapting Bernd Petersohn's answer slightly, we then have:
class EntryProxy(Entry):
@property
def category(self):
return CategoryProxy.objects.get(id=self.category_id)
This ought to be more economical with the database. For added improvements you could set a private attribute (self._category
) the first time the method is called, then return that all subsequent times.