I have a model that looks something like this:
class Link(meta.Model):
fields = (
meta.IntegerField('ID', primary_key=True, editable=False),
...
meta.ForeignKey(Cat, verbose_name='Category'),
meta.ForeignKey(Cat, verbose_name='Subcategory'),
...
...
)
and there are a bunch of other ForeignKeys there too. Anyway, I'm
looping through link object and I need to print out the name of the
category of each link. So at first I just used link.get_category. But
that meant having a lot of SELECT statements causing bad performance.
So I want to use select_related=True but I only want to cache the
category names but not all the other foreignkey stuff (because it's
just too much + I got a traceback when I tried it).
So would it be possible to expand the functionality of select_related
so you could choose what gets cached?
Something like:
link.get_objects(select_related=['Cat'])