I got an error, ValueError at /app/top/ The view app.views.top didn't return an HttpResponse object. It returned None instead. I wrote codes in views.py
from .models import POST
from django.shortcuts import render
def top(request):
contents = POST.objects.order_by('-created_at')
render(request, 'top.html', {'contents': contents})
in models.py
from django.db import models
class POST(models.Model):
title = models.CharField(max_length=100)
text = models.TextField()
in html
<body>
<div>
{% for content in contents.all %}
<div>
<h2>{{ content.title }}</h2>
<p>{{ content.text }}</p>
</div>
{% endfor %}
</div>
</body>
In model, several data of title&text is registed,so surely data is not empty.I think this is directory mistake, now my application structure is
-mysite(parent app)
-app(child app)
-templates
-top.html
-models.py
-views.py
so I do not know what is wrong.How should I fix this?What is wrong in my codes?