Monday, July 28, 2014

pass variable value store in dictionary to url parameter

I pass dict

addon_id_value_mapping =             {'menu': '1', 'opening_hour': '2', 'books': '3', 'doctors': '4'}

and

addon_list = [{u'menu': [{u'price': 50, u'name': u'Momo', u'price_level': u'cheap'},                       {u'price': 510, u'name': u'potato', u'price_level': u'expensive'},                       {u'price': 100, u'name': u'Chowmein', u'price_level': u'expensive'}]},            {u'opening_hour': [{u'close': 17, u'open': 9, u'day': 0},                                {u'close': 17, u'open': 9, u'day': 1},                               {u'close': 16, u'open': 8, u'day': 2}]}]

from view to django-template. I can access the value of the dict using template-tags to display but I couldn't able to pass in url field. What should I need to do to pass variable value that store in dict in url parameter

{% if addon_list %}        {% for addon_name in addon_list %}          {% for key, values in addon_name.iteritems %}              <table>              <tr>                  <td>                      <h2>{{ key }}</h2>{# title- menu #}                  </td>                      <td>                      <h5><a href="{% url 'addon:update_addon' spot_id addon_id %}">                          update</a></h5>                  </td>                  {#todo <I need value of key variable above to replace addon_id. for key== menu I need 1 value>#}              </tr>                <tr>              </tr>                {% for value in values %}                  {% for k,v in value.iteritems %}                      <tr>                          <td>{{ k }}</td>                          <td>{{ v }}</td>                      </tr>                  {% endfor %}              {% endfor %}          {% endfor %}      {% endfor %}  </table>  {% endif %}

I'm using Django 1.6.5

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/11e60ab4-be7f-4d83-a308-001c0916f13a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment