Answer the question
In order to leave comments, you need to log in
How to make a similar view in django?
Me again)
slider.model
class Slide(models.Model):
image = models.ImageField(u'Изображение')
header = models.CharField(u'Заголовок', max_length=120, blank=False)
caption = models.CharField(u'Описание', max_length=250, blank=False)
def slider(request):
slides = Slide.objects.all()
return render(request, 'main.html', {'slides': slides})
class Promo(models.Model):
image = models.ImageField(u'Изображение')
header = models.CharField(u'Заголовок', max_length=120, blank=False)
caption = models.CharField(u'Описание', max_length=250, blank=False)
def promotion(request):
promos = Promo.objects.all()
return render(request, 'base.html', {'promos': promos})
url(r'^$', 'slides.views.slider'),
url(r'promo/', 'promos.views.promotion'),
<head>
{% include 'head.html' %}
</head>
<body>
<div class="container">
{% include 'navbar.html' %}
<div class="content">
{% block content %}
{% endblock %}
</div>
<div class="footer">
{% include "promo.html" %}
</div>
</div>
</body>
{% extends 'base.html' %}
{% block content %}
{% include 'slider.html' %}
{% endblock %}
Answer the question
In order to leave comments, you need to log in
https://toster.ru/answer?answer_id=572613#answers_...
only instead of {'context': data} it will be {'promos': promos}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question