Thanks for the help, guys. Sorry about taking a long time to respond, I got
pulled onto some other tasks.

They wanted to order the products per-category, so I ended up using
django-sortedm2m and migrating the product-category relation to a sorted
m2m. I then had to modify the page processor so it would accept
"'shop_product_categories.sort_value'" as a sort order. All that was needed
for that was to use a queryset based on page.category.products. I did it a
slow way that basically just used id__in to filter based on the already
computed list. My guess is you could do it properly by making a version of
ProductsManager.published that returns a Q. (Unless there's a more direct
way to filter one qs with another? Idk, I'm no DjangoMaster, I'd rather be
writing SDL.) In my case, this is fairly feasible as I'm already modifying
it to do per-user-per-page permissions, so I could just refactor my
published method into a part that makes a Q and a part that applies it.

Anyhow, doing it this way gives you a sort order that is different
per-category. It was a bit brainhurt to actually cobble together, but it
does the thing. What I learned is that with custom m2ms, where you start
the queryset has effects on what you can query by. Or in other words,
related managers exist. I guess I knew that, but not what it meant for
querying.

On 8 April 2016 at 16:27, Eduardo Rivas <[email protected]> wrote:

> I've used Django admin sortable (
> https://github.com/iambrandontaylor/django-admin-sortable) to add
> drag-n-drop ordering to models that are not inlines. It adds a new button
> to the list display where you can do the sorting.
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Mezzanine Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/mezzanine-users/vZCr4K6Qk4M/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to