class KcalDetailView(DetailView):
model = User
context_object_name = 'target_kcal'
template_name = 'kcalculatorapp/detail.html'
def get_context_data(self, **kwargs):
kcl = self.request.user.kcal
context = super().get_context_data(**kwargs)
i = 0
kcal_list = []
while i < 13:
i = i + 1;
if kcl.goal == 'diet':
kcal_list.append((kcl.weight -round((500/7000)*i,2) ))
else:
kcal_list.append((kcl.weight + round((500 / 7000) * i,2)))
context['kcal_list'] = kcal_list
return context
this chart use.
templates.html
.
.
.
<script>
.
.
.
series: [{
name: 'a',
data: {{ kcal_list }} // this !!!
}]
});
</script>
For example kcal_list = [ 10, 13, 15, 16, 20 ] It's in the form of a list.
And data: [10, 13, 15, 16, 20] Why does it look like this?
data : {{kcal_list}} is not possible?
What should I do?