D
D
Dmitry2016-05-17 19:09:14
Django
Dmitry, 2016-05-17 19:09:14

Why is data not updating in django templates?

There is a page that displays data: the sum of a column from one table using an aggregator. After adding data to the database, there are no changes on the page, changes will only occur after the project is reloaded. django template engine.

#view.py
from .model import Video as video
def static_index(request):
    sum = video.objects.aggregate(Sum('chanters'))  
    return render(request, 'index.html',{
'sum': sum
                                         })
#index.html
{{ sum }}

#model.py
class Video(models.Model):
    owner = models.ForeignKey(User, default='1')
    video = models.CharField(max_length=250, unique=True)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
NaName, 2016-05-17
@NaName

{{ sum }} replace with {{ sumchanters }} in index

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question