I found that if i use the original product pull:
{% for product in category.product_set.active %}
{% if forloop.first %} <ul class="sub-nav"> {% endif %}
<li><a
href="{{ product.get_absolute_url }}">{{ product.translated_name }}</
a> {% if product.featured %}Featured{% endif %}</li>
{% if forloop.last %} </ul> {% endif %}
{% endfor %}
Note the: {% if product.featured %}Featured{% endif %}
that actualy works. but what i really need, as i have a more complex
for loop is to be able to pull just the featured, is it possible to
rework the orginal statement:
{% for product in category.product_set.active %} into something
like:
{% for product.featured in category.product_set.active %} ?
Grant it, I've already tried the exact above and not successful, but
if there is another way, as I'm trying to avoid
Costantino's suggestion, mainly because I don't want to change the
Satchmo code, and also, I really don't know how I'd get that info to
my template once added to the views.py file.
Thanks everyone with your help!
nb
On Apr 30, 1:49 pm, "Bruce Kroeze" <
bkro...@gmail.com> wrote:
> Neal, I think you should make a custom view similar to that proposed by
> Constantino. The only modification would be to add "featured=True" to his
> query.
>
> On Wed, Apr 30, 2008 at 10:35 AM, Costantino Giuliodori <
>
>
>
>
costantino.giuliod...@gmail.com> wrote:
>
> > 2008/4/30 Neal Blackburn <
cybernet...@gmail.com>:
>
> > > Alright, thanks Bruce, this is looking good. Now is there a way to
> > > pull featured products on the category page? like /category/cakes/ i
> > > want to run your loop on it pulling just featured items that belong to
> > > cakes... make sense?
>
> > Hi,
> > I have do something like this in shop/views/category.py
>
> > [...]
> > products = Product.objects.active()
> > subcategories = category.get_all_children()
> > if subcategories:
> > q = Q( category=subcategories[0] )
> > if len( subcategories ) > 1:
> > for c in subcategories[1:]:
> > q = q | Q( category=c )
> > products = products.filter( q )
> > number_subcategory_products = products.count()
> > products = products.order_by('?')[:ppp]
> > results = { 'category': category , 'products': products ,
> > 'subcategory': 1 , 'number_subcategory_products' :
> > number_subcategory_products , 'number_subcategory': len( subcategories )}
> > else:
> > results = { 'category': category , }
>
> --