Changeset View
Changeset View
Standalone View
Standalone View
blog/models.py
| Show First 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | class PostComment(models.Model): | ||||
| """An intermediary model between Post and Comment. | """An intermediary model between Post and Comment. | ||||
| A PostComment should in fact only relate to one Comment, hence the | A PostComment should in fact only relate to one Comment, hence the | ||||
| OneToOne comment field. | OneToOne comment field. | ||||
| """ | """ | ||||
| post = models.ForeignKey(Post, on_delete=models.CASCADE) | post = models.ForeignKey(Post, on_delete=models.CASCADE) | ||||
| comment = models.OneToOneField(Comment, on_delete=models.CASCADE) | comment = models.OneToOneField(Comment, on_delete=models.CASCADE) | ||||
| def get_absolute_url(self) -> str: | |||||
| return self.post.url | |||||