Django could not parse the remainder

2,218 views
Skip to first unread message

Koushik Romel

unread,
Jun 20, 2022, 10:52:46 AM6/20/22
to Django users
When trying to get a value from restapi in for loop to display it takes hyphen(-) as minus(-). And there is no way to change the api structure because it is fixed.
Im struck in this anyone help me..
The exact error and the expected json is given below is down below

when i try to print {{key}} the whole for loop data it displays like this
{'_id': ObjectId('xxxxxxxxxxx'), 'date': 'jun/20/2022', 'dst-active': 'false', 'gmt-offset': '+05:30', 'time': '20:19:04', 'time-zone-autodetect': 'true', 'time-zone-name': 'Asia/Kolkata'}

when i specify {{key.dst-active}} it throws this error
TemplateSyntaxError at /store/Could not parse the remainder: '-active' from 'key.dst-active'

Ryan Nowakowski

unread,
Jun 23, 2022, 9:45:08 AM6/23/22
to Django users

Lakshyaraj Dash XI-D 25

unread,
Jun 23, 2022, 10:17:14 AM6/23/22
to django...@googlegroups.com
You can have a template filter that can parse your dictionary.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20220623134418.GE18918%40fattuba.com.

Shaheed Haque

unread,
Jun 23, 2022, 1:05:32 PM6/23/22
to django...@googlegroups.com
From memory, At least in Jinja templates, you can explicitly use the dictionary form {{ key["hypen-ated"] }}... Have you tried that? 

Reply all
Reply to author
Forward
0 new messages