0

I have the following loop:

for elem in Data.objects.filter(user=id):
                variables['labels'].append(time.strftime("%H%M%S", time.localtime(elem.timestamp)))

This produces the following result:

['000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000']

But when I inspect the html this is the result:

labels: ['000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000', '000000']

Why this happens?

Lechucico
  • 1,914
  • 7
  • 27
  • 60
  • 2
    `'` means a single quote in HTML. See https://stackoverflow.com/q/2428572/10077 Does the HTML render the way you want it to? – Fred Larson Apr 10 '18 at 18:39
  • I'm using the following to render the html: `return render(request, 'interface/data.html', {'user_id': id, 'data': variables})`. How I can fix that? – Lechucico Apr 10 '18 at 20:58

1 Answers1

0

I've solved it with the following filter:

{{ data.labels|safe }}
Lechucico
  • 1,914
  • 7
  • 27
  • 60