I have two models.
class Post(models.Model):
title = models.CharField(max_length=150)
class Attachment(models.Model):
type = models.CharField(choices=AttachmentChoices.get_choices(), max_length=15)
link = models.URLField()
post = models.ForeignKey('Post', on_delete=models.PROTECT, related_name='attachments')
I want to do something like this in meta class of Post model
class Meta:
unique_together = [('title', 'attachments')]
but it dosn't work couse django can't find attachments field. Is there a solution provided by django that can solve this problem.