from django.contrib.contenttypes.fields import GenericRelation from .models import get_comment_threads class CommentableMixin: """ Mixin for models that should have comment functionality. Uses composition instead of inheritance to avoid historical model issues. """ @property def comments(self): """Get comments helper for this instance.""" if self.__class__.__name__.startswith('Historical'): # Historical models delegate to their current instance return self.instance.comments return get_comment_threads(self)