Flesh out detail view for Posts
This commit is contained in:
parent
32636b15b6
commit
641ace957b
3 changed files with 16 additions and 2 deletions
|
|
@ -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": [
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
14
flangr/templates/posts/post_detail.html
Normal file
14
flangr/templates/posts/post_detail.html
Normal 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>
|
||||
Loading…
Add table
Reference in a new issue