Ok its solved now, I updated my nested regroup with the following {% regroup dict by col_mapper as column_gr %}
{% for column in column_gr %} {{ column.grouper }}<br> {% with column.list as groupr %} {% regroup groupr by main_title as item_gr %} {% for ggc in item_gr %} {{ ggc.grouper }}<br> {% for i in ggc.list %} {{ i.list_title }}<br> {% endfor %} {% endfor %} {% endwith %} {% endfor %} On Fri, Apr 15, 2011 at 4:39 PM, Mo Mughrabi <mo.mughr...@gmail.com> wrote: > Hi, > > I've been working on a project that takes into consideration performance as > the top priority therefore am trying to use single to queries at each page > to collect all the needed information. > > Any who, I got to a point where I have one query set that need to be > regrouped based on column (left, right, center) and then again regrouped > based on title. The logic is working fine, but when the second regroup > starts it will take the entire queryset meanwhile I only need to regroup > items that are on the left or center..etc. so, I searched for functions to > remove items from the queryset without hitting the database and only thing I > could find was to build a custom template which is where I got stuck :) > > > This is my query result > > > > +------------+-------------------+------------+-----------+----+-----------+-----------+---------+----+-------------+-------------+ > | col_mapper | list_title | main_title | list_slug | id | slug > | is_active | site_id | id | domain | name | > > > +------------+-------------------+------------+-----------+----+-----------+-----------+---------+----+-------------+-------------+ > | L | gadget | for sale | gadget | 2 | > for-sale | 1 | 1 | 1 | example.com | example.com | > | L | furniture | for sale | frnture | 2 | > for-sale | 1 | 1 | 1 | example.com | example.com | > | L | engines | for sale | engines | 2 | > for-sale | 1 | 1 | 1 | example.com | example.com | > | L | women seeking men | personals | wsm | 1 | > personals | 1 | 1 | 1 | example.com | example.com | > | L | missed connection | personals | misd-conn | 1 | > personals | 1 | 1 | 1 | example.com | example.com | > | L | men seeking women | personals | msw | 1 | > personals | 1 | 1 | 1 | example.com | example.com | > | R | massage | services | massage | 3 | srvces > | 1 | 1 | 1 | example.com | example.com | > | R | computers | services | compters | 3 | srvces > | 1 | 1 | 1 | example.com | example.com | > > > +------------+-------------------+------------+-----------+----+-----------+-----------+---------+----+-------------+-------------+ > > > In my template, I did something like this > > {% regroup dict by col_mapper as column_gr %} > > {% for column in column_gr %} > {{ column.grouper }}<br> > > {% regroup column.list by main_title as item_gr %} > {% for i in item_gr %} > {{ i }} > {% endfor %} > {% endfor %} > > The first regroup is working fine, but once it gets to the second regroup > it regroups again the whole queryset while I want to only regroup where > col_mapper is equal to col_mapper.grouper. I tried to build a custom tag, > but most the approaches I know they will cause the queryset to hit the > database again for filtering. > > Any suggestions? > > -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.