Select only two posts from a database list and show them on a HTML page

2008-11-05 Thread Bobo
Hi everyone, In my Django project I’ve on the front page a table where I wish to load the two newest messages. Then I’ve a link to a message archive where all messages are listed. My problem is that I don’t know how to “filter” my list at my front page so it only extracts the two newest messages

Re: Select only two posts from a database list and show them on a HTML page

2008-11-05 Thread Daniel Roseman
On Nov 5, 11:34 am, Bobo <[EMAIL PROTECTED]> wrote: > Hi everyone, > > In my Django project I’ve on the front page a table where I wish to > load the two newest messages. Then I’ve a link to a message archive > where all messages are listed. > > My problem is that I don’t know how to “filter” my l

Re: Select only two posts from a database list and show them on a HTML page

2008-11-05 Thread Ronny Haryanto
On Wed, Nov 5, 2008 at 6:34 PM, Bobo <[EMAIL PROTECTED]> wrote: > In my Django project I've on the front page a table where I wish to > load the two newest messages. Then I've a link to a message archive > where all messages are listed. > > My problem is that I don't know how to "filter" my list a

Re: Select only two posts from a database list and show them on a HTML page

2008-11-05 Thread JoeJ
I would guess that this version: messages = Message.objects.order_by('-created')[:2] would be more memory efficient than the: messages = Message.objects.all() (and then using |slice:":2" to cut out the top 2) although, I've done that second one often. -- joe On Nov 5, 6:56 am, "Ro

Re: Select only two posts from a database list and show them on a HTML page

2008-11-05 Thread Ronny Haryanto
On Wed, Nov 5, 2008 at 8:23 PM, JoeJ <[EMAIL PROTECTED]> wrote: > I would guess that this version: > messages = Message.objects.order_by('-created')[:2] > > would be more memory efficient than the: > messages = Message.objects.all() > (and then using |slice:":2" to cut out the top 2) > > a