HubL - query_dict - get keys and values

SOLVE
Highlighted
Occasional Contributor

hi all

 

if i print the query_dict i would get this:

{yr=2014, onoff=0}

 

i would like to get the keys as well as the values for further use but manage only to get the values. how could i read the key's?

1 | yr | 2014
2 | onoff | 0

 

unfortunately this did not work:

{% for key, value in request.query_dict %}
  {{ loop.index }} | {{ key }} | {{ value }}<br>
{% endfor %}

1 Accepted solution

Accepted Solutions
Highlighted
Solution
Regular Advisor | Partner
0 Upvotes
6 Replies 6
Highlighted
HubSpot Product Team

Hey @diavolino are you still having difficulty? Are you able to select deal stage before creating a new deal?

0 Upvotes
Highlighted
Top Contributor | Platinum Partner
Top Contributor | Platinum Partner

Can confirm, this only returns the values, not the keys

0 Upvotes
Highlighted
Regular Advisor | Partner

@diavolino I think you forgot the ".items()". Try this:

{% for key, value in request.query_dict.items() %}
  {{ loop.index }} | {{ key }} | {{ value }}<br>
{% endfor %}
Stefen Phelps, Community Champion, Kelp Web Developer
Highlighted
Top Contributor | Platinum Partner
Top Contributor | Platinum Partner

Thanks @stefen , that worked. Is there no documentation on this anywhere? The only reference I found on the hubl documentation is for the general request.query_dict term.

0 Upvotes
Highlighted
Solution
Regular Advisor | Partner
0 Upvotes
Highlighted
Top Contributor | Platinum Partner
Top Contributor | Platinum Partner

Ahh yes, I missed the ".items()" part. Too used to other languages not having it!

 

Thanks a lot!

0 Upvotes