On Sat, Sep 21, 2013 at 7:07 PM, Klerik <[email protected]> wrote:
> hi guys,
>
> I have one big problem. I need in my base teplate dynamically render my
> categories (my web is blog with categories - http://www.klerik.cz [this
> is old
> production version with staticaly rendered categories - in left column]).
> So I create one global variable with this code:
>
> web.template.Template.globals['seznam_kategorii'] =
> databaze.select("kategorie", order="cislo ASC")
>
> and on base.html I only print with for cycle all categories and all works
> great:
> $for kategorie in seznam_kategorii:
> <a href="/kategorie/"$kategorie.url_kategorie>$kategorie.kategorie</a>
>
> bud this work only 1 times! when I make page refresh, then the categories
> are
> gone (only empty space - like nothig in code).
>
> Is here solution for me?
>
The issue is with
databaze.select("kategorie", order="cislo ASC")
It returns an iterator, which is consumed after first use. Change that to
the following to fix the issue.
databaze.select("kategorie", order="cislo ASC").list()
Anand
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/webpy.
For more options, visit https://groups.google.com/groups/opt_out.