One last thought.
By writing a wrapper, does this not limit the random book object to teh
wrapped view?
So, If I wanted to use it elsewhere, (say in the sidebar, or the forums
page), I would have to re-write teh code/wrapper?
Would it not be easier to make this a method of the model class. I
On Nov 9, 2007 10:32 PM, Hani <[EMAIL PROTECTED]> wrote:
> What I want to do is display 1 random book on the main page. I
> currently use a generic view to display a list of books on the main
> page but I also want a random book highlighted. (imagine two columns
> on the main page, one is the
Loren, Kenneth and Joe,
Thanks for your response. I'm going to try your code and see.
Thanks,
Hani
On Nov 9, 8:21 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 10-Nov-07, at 12:56 AM, LorenDavie wrote:
>
> > import random
> > Book.objects.all()[random.randint(0,Book.objects.count()-1]
Hi again James,
The section speaks to ordering the set randomly. I understand this to
mean that the sort would be random. Is this incorrect?
What I want to do is display 1 random book on the main page. I
currently use a generic view to display a list of books on the main
page but I also want a
On 10-Nov-07, at 12:56 AM, LorenDavie wrote:
> import random
> Book.objects.all()[random.randint(0,Book.objects.count()-1]
Book.objects.order_by('?')[0]
--
regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/web/
--~--~-~--~~~---~--~~
You
How about :
Book.objects.order_by('?')[:1].get()
On Nov 9, 2:26 pm, LorenDavie <[EMAIL PROTECTED]> wrote:
> How about this:
>
> import random
> Book.objects.all()[random.randint(0,Book.objects.count()-1]
>
> On Nov 9, 2:00 pm, Hani <[EMAIL PROTECTED]> wrote:
>
> > Hi James,
>
> > I did go
How about this:
import random
Book.objects.all()[random.randint(0,Book.objects.count()-1]
On Nov 9, 2:00 pm, Hani <[EMAIL PROTECTED]> wrote:
> Hi James,
>
> I did go through the API documentation but did not find what I wanted.
> Please note that I am both a Django and Python newbie so its
On Nov 9, 2007 1:00 PM, Hani <[EMAIL PROTECTED]> wrote:
> I did go through the API documentation but did not find what I wanted.
> Please note that I am both a Django and Python newbie so its likely I
> did not 'get it'. Would you direct me to the pertinent topic/heading/
> paragraph?
Hi James,
I did go through the API documentation but did not find what I wanted.
Please note that I am both a Django and Python newbie so its likely I
did not 'get it'. Would you direct me to the pertinent topic/heading/
paragraph?
And I did not take your response as mean. No worries. :)
On
On Nov 9, 2007 12:44 PM, Hani <[EMAIL PROTECTED]> wrote:
> What I would like to do is create a method to the model, say
> random_id, so that object.random_id will access a random instance.
I'm not trying to be mean, but what you should do is read Django's
database API documentation, which
Hi,
I have a model, Books. On the main page of the site, I want to pull
and display the details for a random book.
What I would like to do is create a method to the model, say
random_id, so that object.random_id will access a random instance.
Would I define a function in the model definition
11 matches
Mail list logo