CMS Development

diavolino
Participant

HubL - query_dict - get keys and values

SOLVE

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
stefen
Solution
Key Advisor | Partner
Key Advisor | Partner

HubL - query_dict - get keys and values

SOLVE
6 Replies 6
stefen
Key Advisor | Partner
Key Advisor | Partner

HubL - query_dict - get keys and values

SOLVE

@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
LPM
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

HubL - query_dict - get keys and values

SOLVE

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
stefen
Solution
Key Advisor | Partner
Key Advisor | Partner

HubL - query_dict - get keys and values

SOLVE
LPM
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

HubL - query_dict - get keys and values

SOLVE

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

 

Thanks a lot!

0 Upvotes
LPM
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

HubL - query_dict - get keys and values

SOLVE

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

0 Upvotes
roisinkirby
HubSpot Product Team
HubSpot Product Team

HubL - query_dict - get keys and values

SOLVE

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

0 Upvotes