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 list and the second is the detailed info > about the random book). As a beginner, I don't yet feel comfortable in > extending the generic view so I am exploring how else this can be > done.
Writing a wrapper around a generic view which pulls a random Book object and puts it into the context via the "extra_context" argument is probably the most natural way to do this with Django, though; the technique is actually pretty easy, and a while back I wrote up a short article on how to do it (and some other uses): http://www.b-list.org/weblog/2006/nov/16/django-tips-get-most-out-generic-views/ > My thought was by creating a method of class Books that is a > random ID for books, it would become part of the context passed to the > template and I can just access it via object.random_id. Not doable? > (Do I even make sense?) Doable, but more complex than it needs to be ;) -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---