fixed indexing

This commit is contained in:
Rushil Umaretiya 2020-10-21 22:41:48 -04:00
parent a631263a4c
commit 680d7786cf
2 changed files with 8 additions and 12 deletions

View File

@ -11,7 +11,7 @@
<p class="lead">We are the class to beat!</p>
</div>
</div>
<div class="container news mb-5">
<div class="container news mb-2">
<h1 class="text-center font-weight-bold">2023 News</h1>
<br><br>
<div class="row">
@ -27,7 +27,7 @@
</div>
</div>
{% if bar %}
{% for bar in bars %}
<div class="container news">
<h1 class="text-center font-weight-bold">{{ bar.name }}!</h1>
<br><br>
@ -55,5 +55,5 @@
});
</script>
</div>
{% endif %}
{% endfor %}
{% endblock content %}

View File

@ -4,21 +4,17 @@ from .models import Story, Bar
# Create your views here.
def index(request):
try:
stories = Story.objects.all().order_by('-created')
bar = Bar.objects.all()[0]
stories = stories[:3]
except Exception:
stories = []
bar = None
stories = Story.objects.all().order_by('-created')[:3]
bar = Bar.objects.all()[:1]
context = {
'stories': stories,
'animate': True,
'bar': bar
'bars': bar
}
print(stories)
return render(request, 'pages/index.html', context)
return render(request, 'pages/index.html', context=context)
def council(request):