Flesh out detail view for Posts

This commit is contained in:
Maximilian Friedersdorff 2022-07-04 22:19:21 +01:00
parent 32636b15b6
commit 641ace957b
3 changed files with 16 additions and 2 deletions

View file

@ -53,7 +53,7 @@ ROOT_URLCONF = "flangr.urls"
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [],
"DIRS": ["flangr/templates"],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [

View file

@ -31,7 +31,7 @@ class Collection(models.Model):
class Comment(models.Model):
post = models.ForeignKey("Post", on_delete=models.CASCADE)
post = models.ForeignKey("Post", on_delete=models.CASCADE, related_name="comments")
comment = models.CharField(max_length=255)
user = models.ForeignKey(

View file

@ -0,0 +1,14 @@
<body>
{% if object.title %}
<h1>{{ object.title }}</h1>
{% else %}
<h1>{{ object.user.username }}</h1>
{% endif %}
<img width=400 src={{ object.img.url }}/>
<h2> Comments</h2>
<ul>
{% for comment in object.comments.all %}
<li>{{ comment.user }} - {{ comment.comment }}</li>
{% endfor %}
</ul>
</body>