On Jan 5, 5:56 pm, bruno desthuilliers <bruno.desthuilli...@gmail.com>
wrote:
> On 5 jan, 23:39, "django_fo...@codechimp.net" <codech...@gmail.com>
> wrote:
>
> > I have a pretty simple template that needs to print some data in a
> > bunch of table rows.  I have done something like this:
>
> > <table>
> > {% if my_art_list %}
> >         {% count = 0 %}
>
> This just won't work

Obviously...

>
> >         {% for art in my_art_list %}
> >                 {% if count%3 = 0 %}
>
> idem
>
> >                 <tr>
> >                 {% endif %}
> >                         <td>
> >                                 <img src="{{ art.img_path }}" alt="{{ 
> > art.title }}" />
> >                         </td>
> >                 {% if count%3 = 2 %}
>
> idem
>
> >                 </tr>
> >                 {% endif %}
> >         {% endfor %}
> >         </tr>
> > {% else %}
> >         <p>You have no art pieces to view.  Would you like to add some?</p>
> > {% endif %}
> > </table>
>
> > However, as you probably suspect, the "count" variables cause all
> > sorts of trouble.
>
> The first one being it's not valid.

Again, figured this out from the variable...

>
> >  Is there a way to have tracking variables in the
> > template code?
>
> Read the documentation for the {% for %} template tag - it sets a
> {{ forloop.counter }} variable.
>
> http://docs.djangoproject.com/en/dev/ref/templates/builtins/#for
>
> You may also want to have a look at the {% cycle %} tag (same page as
> above), and / or be interested in the "partition" filters on
> djangosnippets:http://www.djangosnippets.org/snippets/6/http://www.djangosnippets.org/snippets/401/

Thanks for pointing me to the right place...

>
> > I was under the impression that the {%  %} tags were
> > just straight Python code
>
> I don't know where you got this impression from. Oh, wait : you didn't
> read the doc, did you ?

Read below...

>
> > and would execute as such, but apparently my
> > understanding is a little less than adequate.
>
> I do confirm !-)
>
> > Please help me sort this out...
>
> Well... What about reading the online documentation first ?-)
>
> HTH

First, let me take some Motrin for my very sore rear end.  I have been
reading documentation.  In fact, I started with the tutorials on the
site that walks you through writing the polling application, then
moved on to some docs at http://www.djangobook.com.  It's sometimes
hard to find the one mention of a certain subject when you don't know
what it is you are really looking for.  The page I found on template
blocks, located here http://www.djangobook.com/en/beta/chapter04/,
didn't really tell me much.

I think the biggest problem is that I have some overlap of experience
with JSPs, PHP, and Ruby, all of which use an in-line server side
include tag similar to the one here.  I guess in my reading it just
seemed to make sense that these where server side includes and not
just some template replace thing, but again that just shows my age on
the product.

I do sincerely thank you for helping me get it straight.  I know that
sometimes the newbs ask very dumb questions.  As someone that has had
to deal with them in other languages I know it can be frustrating and
repetitive.  You sometimes have to remember that the skills you have
had to start somewhere, and that you probably made your own stupid
mistakes and got stuck on something just as us who are starting out
have.
--~--~---------~--~----~------------~-------~--~----~
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