Got it.
Thanks Aziz :)

On May 11, 2:12 pm, "azizmb.in" <m...@azizmb.in> wrote:
> Off the top of my head, you could keep nesting the dictionary.
>
> eg:
>
> module_tests = {
>     "module1": {
>         "test1": {
>             "action1": ["step1", "step2", "step3"],
>             "action2": ["step1", "step2", "step3"]
>             },
>         "test2": {
>             "action1": ["step1", "step2", "step3"],
>             "action2": ["step1", "step2", "step3"]
>             }
>         },
>     "module2": {
>         "test1": {
>             "action1": ["step1", "step2", "step3"],
>             "action2": ["step1", "step2", "step3"]
>             },
>         "test2": {
>             "action1": ["step1", "step2", "step3"],
>             "action2": ["step1", "step2", "step3"]
>             }
>         }
>     }
>
>
>
>
>
>
>
>
>
> On Fri, May 11, 2012 at 11:31 AM, Wally Yu <dayu.e...@gmail.com> wrote:
> > Thanks Aziz. You really helps a lot.
> > But what if I have deeper level of looping? Say I have a template like
> > this:
>
> > {% for module, tests in module_tests.items %}
> >       <li>
> >               <h3>Automation Test Result for Test Suite: {{ module}}</
> > h3>
> >               <div class="acc-section">
> >                       <div class="acc-content">
> >                               {% for tc in tests %}
> >                               .....
> >                                ......
> >                                      {% for action in actions %}
> >                                      ......
> >                                      ......
> >                                              {% for step in steps %}
> >                                              ......
> >                                              {% endfor %}
> >                                               ......
> >                                       {% endfor %}
>
> >                              {% endfor %}
> >       ...
>
> > {% endfor %}
>
> > A case like above, I think it's hard to work with dictionary. Do you
> > have better data structure for that?
>
> > Thanks,
> > Wally
>
> > On May 11, 1:26 pm, "azizmb.in" <m...@azizmb.in> wrote:
> > > AFAIK, django templates dont support what you are trying to do. You could
> > > check some answers
> > > here<
> >http://stackoverflow.com/questions/4063515/django-template-question-a...>
> > > .
>
> > > I would restructure the data being passed to the template to something
> > like
> > > this:
>
> > > module_tests = {
> > >     'module1': ['TC1','TC2','TC3'],
> > >     'module2': ['Case1', 'Case2']
>
> > > }
>
> > > and then in your template:
>
> > > {% for module, tests in module_tests.items %}
> > >        <li>
> > >                <h3>Automation Test Result for Test Suite: {{
> > module}}</h3>
> > >                <div class="acc-section">
> > >                        <div class="acc-content">
> > >                                {% for tc in tests %}
> > >                                .....
>
> > > >                      {% endfor %}
> > > >       ...
>
> > > {% endfor %}
>
> > > On Fri, May 11, 2012 at 9:37 AM, Wally Yu <dayu.e...@gmail.com> wrote:
> > > > Hi all,
>
> > > > I'm wondering if Django template supports nested tags? Here is my
> > > > situation:
>
> > > > My Template:
>
> > > > <div id="body">
> > > > <ul class="acc" id="acc">
> > > >        {% for module in modules %}
> > > >        <li>
> > > >                <h3>Automation Test Result for Test Suite: {{
> > module}}</h3>
> > > >                <div class="acc-section">
> > > >                        <div class="acc-content">
> > > >                                {% for TC in
> > > > TCs.{{forloop.parentloop.counter0}} %}
> > > >                                 ... ...
>
> > > >                                 {% endfor %}
> > > >       ... ...
> > > >       {% endfor %}
>
> > > > Here are the Lists I'm trying to pass into template:
> > > >  - modules = ['module1', 'module2']
> > > >  - TCs = [['TC1','TC2','TC3'],['Case1','Case2']]
>
> > > > But seems "{% for TC in TCs.{{forloop.parentloop.counter0}} %}" is not
> > > > working... That probably because a "forloop" is inside a "for" tag.
> > > > The error message is:
> > > > "Could not parse the remainder: '{{forloop.parentloop.counter}}' from
> > > > 'TCs.{{forloop.parentloop.counter}}'"
>
> > > > Does anybody encounter the same problem with me? Could you help share
> > > > your idea to solve it? Thanks in advance.
>
> > > > Thanks,
> > > > Wally
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Django users" group.
> > > > To post to this group, send email to django-users@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > django-users+unsubscr...@googlegroups.com.
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/django-users?hl=en.
>
> > > --
> > > - Aziz M. Bookwala
>
> > > Website <http://azizmb.in/> | Twitter <https://twitter.com/azizbookwala>
> > |
> > > Github <http://github.com/azizmb>
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --
> - Aziz M. Bookwala
>
> Website <http://azizmb.in/> | Twitter <https://twitter.com/azizbookwala> |
> Github <http://github.com/azizmb>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to