i know it may be weird, but let me explain
class Comment(models.Model):
profile = models.ForeignKey(Profile, on_delete=models.CASCADE, related_name='comments')
comment = models.TextField()
target_ct = models.ForeignKey(ContentType, on_delete=models.CASCADE)
target_id = models.PositiveIntegerField()
target = GenericForeignKey('target_ct', 'target_id')
second_level_comment = GenericRelation(Comment, content_type_field='target_ct', object_id_field='target_id')
def __str__(self):
return self.comment[:40]
in the code above I have a generic relation from django and I want to reference to the comment from a comment
I can make it using filter as it's working
but i can't find a solution to put GenericRelation field with a reference to the comment class itself.
I want something like self.__class__
which here doesn't make any sense of course