<div dir="ltr"><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;color:#3d85c6">I think I get your problem now. Right now, it is ordering by post ID. Do you want the comments of a particular post to be ordered by ID, or do you want something like:</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;color:#3d85c6"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;color:#3d85c6">Post 1:</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;color:#3d85c6"> Comment 1</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;color:#3d85c6"> Comment 2</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;color:#3d85c6">Post 2:</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;color:#3d85c6"> Comment 1</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;color:#3d85c6"> Comment 2</div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;color:#3d85c6"><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;color:#3d85c6">?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 20, 2014 at 12:19 PM, Pedro Baumann <span dir="ltr"><<a href="mailto:ondoheer@gmail.com" target="_blank">ondoheer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello Gamebrainiac<div><br></div><div>Thanks for the link, it seems really interesting. </div><div><br></div><div>I have tried both your suggestions and both gave mme the same problem.</div><div><br></div><div>They both return the Post object ordered by id, same as my code did. The problem is that somehow when I iterate through the posts like soÑ</div><div><br></div><div> {% for post in posts %}</div><span class=""><div> {% for comment in post.comments %}</div><div><br></div><div><br></div></span><div>the comments come out in any order, and they change with every request!!!!</div><div><br></div><div>That same thing happens with your suggestions.</div><div>I think this hasn't happend to me with pony before, but somehow it does now. Is there a way to sort the linked table from jinja?</div><div><br></div><div>something like post.comments.order_by(id)?<br><div><br></div><div><br></div></div></div><div class="gmail_extra"><span class=""><br clear="all"><div><div><div dir="ltr"><div><b><br></b></div><b><div><b><br></b></div><div><b><br></b></div><div><b><br></b></div>Pedro Baumann Cornejo</b><div>Psicólogo - Psicoterapeuta - Flores de Bach</div><div>Francisco de Paula Ugarriza 309 dpto. 102 Miraflores.</div><div>Lima</div><div>Perú</div></div></div></div>
<br></span><div><div class="h5"><div class="gmail_quote">On Thu, Nov 20, 2014 at 1:02 AM, Gamesbrainiac <span dir="ltr"><<a href="mailto:gamesbrainiac@gmail.com" target="_blank">gamesbrainiac@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;color:rgb(61,133,198)">In addendum, this is the exact part where I talk about querying: <a href="http://nafiulis.me/a-todo-app-with-flask-and-pony.html#id4" target="_blank">http://nafiulis.me/a-todo-app-with-flask-and-pony.html#id4</a><br></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 20, 2014 at 12:01 PM, Gamesbrainiac <span dir="ltr"><<a href="mailto:gamesbrainiac@gmail.com" target="_blank">gamesbrainiac@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;color:rgb(61,133,198)">Try using:<br><br><span style="font-family:monospace">'"SELECT * FROM "post" ORDER BY "post"."id"'</span><br><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;color:rgb(61,133,198)">If I were you, I'd do the following in pony:<br><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;color:rgb(61,133,198)"><span style="font-family:monospace">Post.select().order_by(Post.id)</span><br><br></div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif;color:rgb(61,133,198)">Also, my post on Pony might be worth a look -> <a href="http://nafiulis.me/a-todo-app-with-flask-and-pony.html" target="_blank">http://nafiulis.me/a-todo-app-with-flask-and-pony.html</a><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Thu, Nov 20, 2014 at 11:43 AM, Pedro Baumann <span dir="ltr"><<a href="mailto:ondoheer@gmail.com" target="_blank">ondoheer@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr">Hello,<div><br></div><div>first of all I want to thank you for creating such an intuitive and pythonic ORM, I have enjoyed every minute if used it, it's most intuitive and it really heps code readability.</div><div><br></div><div>I'm having a small problem with my latest project, I hope you can help me.</div><div><br></div><div>I'm developing a web app that has a basic "blog like" module.</div><div><br></div><div>Post->Comments->Replies</div><div><br></div><div>I'm using Flask as a framework. </div><div><br></div><div>I'm passing <br clear="all"><div><div><div dir="ltr"><div><b><br></b></div><div><b>posts = Post.select_by_sql('SELECT * FROM post ORDER BY id')<br></b></div><div><b><br></b></div><div>to the template, and then iterating through it to print the comments as in </div><div style="font-weight:bold"><b><br></b></div><div><div style="font-weight:bold">{% for comment in post.comments %}</div><div style="font-weight:bold"> {% if loop.index > numberComments %}{% break %}{% endif %} </div><div style="font-weight:bold"> // code code code (HTML)</div><div style="font-weight:bold">{% endfor %}</div><div style="font-weight:bold"><br></div><div>the problem is the comments come out in random order, varying on each iteration.</div></div><div><br></div><div>I need to be able to print the comments in order for my ajax functions that retrieve more comments to work.</div><div><br></div><div>I think I am missing something here. </div><div><br></div><div>Thanks !</div><div style="font-weight:bold"><b><br></b></div><b>Pedro Baumann Cornejo</b><div>Psicólogo - Psicoterapeuta - Flores de Bach</div><div>Francisco de Paula Ugarriza 309 dpto. 102 Miraflores.</div><div>Lima</div><div>Perú</div></div></div></div>
</div></div>
<br></div></div>_______________________________________________<br>
ponyorm-list mailing list<br>
<a href="mailto:ponyorm-list@ponyorm.org" target="_blank">ponyorm-list@ponyorm.org</a><br>
<a href="/ponyorm-list" target="_blank">/ponyorm-list</a><br>
<br></blockquote></div><span><font color="#888888"><br><br clear="all"><br>-- <br><div><div dir="ltr"><div><font face="trebuchet ms, sans-serif" color="#6fa8dc" size="4">Kind Regards,</font></div><div><img src="https://brnbcg.blu.livefilestore.com/y1mIyqRuYWMVkEp1XgqnpPJw31rRYoNvXRcLpo1WOUfIx-d9b0krZq2EJ4vUjOgoHcfZow1IZifvV3JxEuWl7yinOPYSMwlrPk7rFfWQ7RMTlkgQ9uTAq0uNQ/Signature1.png?psid=1" height="69" width="96"><br></div><div></div><div><span style="font-family:'trebuchet ms',sans-serif;font-size:large"><font color="#6fa8dc">Quazi Nafiul Islam</font></span></div></div></div>
</font></span></div>
</blockquote></div><br><br clear="all"><br>-- <br><div><div dir="ltr"><div><font size="4" face="trebuchet ms, sans-serif" color="#6fa8dc">Kind Regards,</font></div><div><img src="https://brnbcg.blu.livefilestore.com/y1mIyqRuYWMVkEp1XgqnpPJw31rRYoNvXRcLpo1WOUfIx-d9b0krZq2EJ4vUjOgoHcfZow1IZifvV3JxEuWl7yinOPYSMwlrPk7rFfWQ7RMTlkgQ9uTAq0uNQ/Signature1.png?psid=1" width="96" height="69"><br></div><div></div><div><span style="font-family:'trebuchet ms',sans-serif;font-size:large"><font color="#6fa8dc">Quazi Nafiul Islam</font></span></div></div></div>
</div>
</div></div><br>_______________________________________________<br>
ponyorm-list mailing list<br>
<a href="mailto:ponyorm-list@ponyorm.org" target="_blank">ponyorm-list@ponyorm.org</a><br>
<a href="/ponyorm-list" target="_blank">/ponyorm-list</a><br>
<br></blockquote></div><br></div></div></div>
<br>_______________________________________________<br>
ponyorm-list mailing list<br>
<a href="mailto:ponyorm-list@ponyorm.org">ponyorm-list@ponyorm.org</a><br>
<a href="/ponyorm-list" target="_blank">/ponyorm-list</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><font size="4" face="trebuchet ms, sans-serif" color="#6fa8dc">Kind Regards,</font></div><div><img src="https://brnbcg.blu.livefilestore.com/y1mIyqRuYWMVkEp1XgqnpPJw31rRYoNvXRcLpo1WOUfIx-d9b0krZq2EJ4vUjOgoHcfZow1IZifvV3JxEuWl7yinOPYSMwlrPk7rFfWQ7RMTlkgQ9uTAq0uNQ/Signature1.png?psid=1" width="96" height="69"><br></div><div></div><div><span style="font-family:'trebuchet ms',sans-serif;font-size:large"><font color="#6fa8dc">Quazi Nafiul Islam</font></span></div></div></div>
</div>