-1

I learning django rest. And now i wont output some json data in html. My json:

{'Resul': {'Period Start': '2017-01-01', 'Period End': '2017-12-12'}}

then i send it json to html:

 context = {'Resul': json_data['date']}
 content = render_to_string('balance.html', context)

json_data['date'] - {'Period Start': '2017-01-01', 'Period End': '2017-12-12'}

in html i write this code

 Period: {{ Resul['Period Start'] }} - {{ Resul['Period End'] }}

but have error:

Could not parse the remainder: '['Period Start']' from 'Resul['Period Start']'
sgauri
  • 694
  • 8
  • 18
nesalexy
  • 848
  • 2
  • 9
  • 30
  • Possible duplicate of [Django templates: value of dictionary key with a space in it](https://stackoverflow.com/questions/2970244/django-templates-value-of-dictionary-key-with-a-space-in-it) – iklinac Feb 27 '18 at 12:44
  • @iklinac no, not dublicat. I create it by myself – nesalexy Feb 27 '18 at 12:56

1 Answers1

2

I strongly recommend you not to use spaces in dictionary key names, change them for underscores and do it like this:

 Period: {{ Resul.Period_Start }} - {{ Resul.Period_End }}
Brian Ocampo
  • 1,345
  • 1
  • 12
  • 22
jsanchezs
  • 1,992
  • 3
  • 25
  • 51