Записи модели Django не отображаются в таблице
Проблема в том, что данные, которые я хочу отобразить, не отображаются, часть нарезки работает, потому что она показывает 5 строк таблицы, содержащих только предопределенное изображение. Amount_of_tweets и демонстрации показывают правильное количество.
Заранее благодарю
Models.py:
class demonstrations(models.Model):
data_id: models.IntegerField()
event_id: models.IntegerField()
event_date: models.DateField()
year: models.IntegerField()
event_type: models.CharField()
sub_event_type: models.CharField()
region: models.CharField()
country: models.CharField()
province: models.CharField()
location: models.CharField()
latitude: models.FloatField()
longitude: models.FloatField()
text: models.CharField()
translation: models.CharField()
fatalities: models.IntegerField()
sentiment_score: models.FloatField()
View.py
@login_required(login_url="/login/")
def index(request):
latest_tweets = tweets.objects.all()[:5]
amount_of_tweets = tweets.objects.all().count()
latest_demonstrations = demonstrations.objects.all()[:5]
amount_of_demonstrations = demonstrations.objects.all().count()
context = {
'segment': 'index',
'latest_tweets' : latest_tweets,
'amount_of_tweets': amount_of_tweets,
'latest_demonstrations': latest_demonstrations,
'amount_of_demonstrations': amount_of_demonstrations,
}
html_template = loader.get_template('home/index.html')
return HttpResponse(html_template.render(context, request))
index.html
{% for demo in latest_demonstrations %}
<tr class="unread">
<td><img style="width:40px;" src="/static/assets/images/icons/image.png" alt="activity-user"></td>
<td>
<h6 class="mb-1">{{ demo.location }}</h6>
<p class="m-0">{{ demo.event_type }}</p>
</td>
<td>
<h6 class="text-muted">{{ demo.event_date }}</h6>
</td>
<td><a href="#!" class="label theme-bg text-white f-12">View</a></td>
</tr>
{% endfor %}