'This is called when the idmapper cache is flushed and
allows customized actions when this happens.
Returns:
do_flush (bool): If True, flush this object as normal. If
False, don\'t flush and expect this object to handle
the flushing on its own.
Notes:
The default implementation relies on being able to clear
Django\'s Foreignkey cache on objects not affected by the
flush (notably objects with an NAttribute stored). We rely
on this cache being stored on the format "_<fieldname>_cache".
If Django were to change this name internally, we need to
update here (unlikely, but marking just in case).'

def at_idmapper_flush(self):

    if self.nattributes.all():
        self.attributes.reset_cache()
        self.tags.reset_cache()
        for field in self._meta.fields:
            name = ('_%s_cache' % field.name)
            if (field.is_relation and (name in self.__dict__)):
                del self.__dict__[name]
        return False
    return True
