views:

20

answers:

1

Hi

I am trying to render the dictionary content using Django template like this
for example : result contain dictionary X

X={a:1,  
   b:1,  
   c:X(dictionary X again)  
   }

This could be any many places and at multiple levels

template : results.html, says something like following

{{a}}  
{{b}}  
{% if X.a %}
  {% include results.html %}  
{% endif %}  

I thought that this would work but I get error saying

maximum recursion depth exceeded while calling a Python object

How could I resolve this?

Thank you

A: 

get rid of the c:X part in your dictionary X, you can't do that.

You can use X or properties included in it twice in your template, so there's no need for nested self-references in your dictionary.

Jasper
@Jasper I am sorry, I didnot get what you saidAre you saying not to render c:X?? well thats part of my program, I need that
learner
you're nesting a dictionary in itself while creating it. It is something like : dict = { a:1, b:2, dict }. The second dict is either empty or you get a complaint about nesting too deep, depending on the situation. Also it adds no new data, your just repeating the whole dictionary. Either that or I am completing missing the point.
Jasper

related questions