I don't understand why is it obvious that an 'else' won't work. If a single {% else %} is not what you want, you can nest {% if %} clauses. But if you are doing this it can also mean that you should move this logic to the view and just pass the final table to the template.
- Paulo On Wed, Mar 24, 2010 at 12:20 PM, ALJ <astley.lejas...@gmail.com> wrote: > I have a template that shows a matrix table of form text input boxes. > When the form is new, then it should be just empty text boxes. If data > already exists, then the form gets repopulated with data. > > What I am looking for it this: > > PRODUCTS | DAY1 | DAY2 | DAY3 > POLO | Empty text box | 3 | 3 > PASSAT | 1 | 0 | 0 > SCIROCCO | Empty text box | Empty text box | 1 > > What I get is this: > > PRODUCTS | DAY1 | DAY2 | DAY3 > POLO | No box | 3 | 3 > PASSAT | 1 | 0 | 0 > PASSAT | No box | No box | 1 > > My template is: > > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > <tr> > <th class="centered">{{ rate.cost_item.name }}</th> > {% for appointment in appointments %} > <td class="centered"> > {% for sale in sales %} > {% if sale.appointment.id == appointment.id and > rate.cost_item.id == sale.cost_rate.cost_item.id %} > <input type="text" name="sales_{{rate.id}} > _{{ appointment.id }}" value="{{sale.units}}" size="4" maxlength="4" > style="text-align:center" /> > {% endif %} > {% endfor %} > </td> > {% endfor %} > </tr> > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > > Obviously, if try to put an 'else' anywhere in that sales loop to say > put an empty text input box, I'll get as many boxes as there are sales > within each table cell. > > Is there anyway to get around this? > Or with I need to create my own filter to do this? > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.