Django query data items 7 views

1, the data found in the views inside, add content

def index(request):
catagories = Category.objects.filter(is_delete=False)

today = "22222"
# return HttpResponse("哈哈哈哈")
data = {'nav':catagories,'today1':today}
return render(request,'index.html',data)

2, add content to modify the index inside, and then displayed on the page

<ul id="starlist">
{% for n in nav %}
<li><a href="index.html">{{ n.name }}</a></li>
{% endfor %}
</ul>

3、

4、

Guess you like

Origin www.cnblogs.com/lapt/p/12112445.html