Thanks alex, I think I'll leave it as-is for now, just getting my teeth cut on writing some simple template tags of my own but I haven't quite figured it all out yet. I'm so glad this list exists though. :-)
//emil On 4 Jan, 23:41, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > How about a template tag? Pass it the image name and have it set a > var to the correct image. > > On Jan 4, 3:29 pm, Emil <[EMAIL PROTECTED]> wrote: > > > Thanks Alex, I'm not quite sure what you mean, but I actually gave it > > another go and got something working. I'm passing the value from the > > image_detail GET-variable ("products/productname/?image_detail=1") > > along with the extra_context to the variable, and looping over the > > image set comparing the value to the id of the image. Feels a bit > > inefficient though: I'm not sure if it's better to try and do that in > > the view? On the other hand, if i do it in the view, the queryset is > > on all products, (even if the generic view drills it down to one > > product in the end) so how do I then "attach" each main image to each > > product so to speak? > > > //emil > > > On 4 Jan, 21:59, Alex Koshelev <[EMAIL PROTECTED]> wrote: > > > > 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 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 -~----------~----~----~----~------~----~------~--~---