Posts

Showing posts with the label django-templates

Get data of another child in a template

Image
Get data of another child in a template I'm making a Board which can write comments. All functions work well. But the only thing I need is displaying profile of the author of the comment. {{ board.title }} {{ board.text }} {% for comment is context.commentmodel_set.all %} {{ comment.comment }} {{ comment.whose.profile??? }} <- ???? {% endfor %} ////////////// EDIT [Add Models] /////////// # Appname : board / model class Board(models.Model): whose = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) title = models.CharField() text = models.TextField() created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) class Comment(models.Model): post = models.ForeignKey(Board, on_delete=models.CASCADE) whose = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) comment = models.TextField() created_at = models.DateTimeField(auto_now_add=True) updated_at = models....