Select needed image object from base and pass it explicitly to template context
On 4 янв, 23:43, Emil <[EMAIL PROTECTED]> wrote: > Greetings, fellow Djangonauts. > > Some background to my question: > I'm building a site where I have Products that each can have one or > more Images (related via a Product f.k on the Image side). The product > images are default ordered by a SmallIntegerField with a priority > rating (of 1-5, 5 being highest). When I show a single product, I use > a generic view (object_detail), through a wrapper function to be able > to filter based on category in the URL among other things. > > Printing out all product images for a product should be fairly easy - > just get the list of images via product.images_set.all. One image is > the "main" image for the product - it's presented bigger, the other > ones are smaller thumbnails. Default, the main image is the one with > highest priority, thus the first one, no problem there. > > Now to the problem: When the user clicks any other image on the > product page, the page should reload but with the clicked image as > main/bigger image instead. Naturally, this should be through some > parameter in the URL (either like "products/productname/image1/" or > "products/productname?image=1", not sure which is cleanest/easiest). > How do I get to filtering out, and assigning a template variable for, > the main image from that parameter? > > It feels like there should be some fairly simple solution here, but I > can't seem to come up with anything... > > //emil --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---

