Category tree not alpha sorted

2 views
Skip to first unread message

Loe Spee

unread,
Sep 18, 2007, 11:21:32 AM9/18/07
to satchm...@googlegroups.com
Today I noticed that the category tree used in the demo store is not alphabetically sorted.
I think it makes no sense at all to sort this list by ID, a alpha sort by default would be more logical I think, possibly with an order overwrite field as seen in other models.

To change this behavior so the tree will show up alphabetically sorted the following patch must be applied to "shop/templatetags/category_display.py".

Patch:
43c43
<     for cats in Category.objects.all ():
---
>     for cats in Category.objects.all().order_by('name'):

Personally I would like to see this behavior activated by default, what do others think?

category_display.py.patch

Loe Spee

unread,
Sep 18, 2007, 11:30:17 AM9/18/07
to satchm...@googlegroups.com
To also sort all child (sub, underlying) categories alphabetically, the following patch should be applied to "shop/templatetags/category_display.py" instead of the above patch.

Chris, if you'd like I could also create a Trac ticket for this issue.

Patch:
22c22
<             children = current_node.child.all()
---
>             children = current_node.child.all().order_by('name')

43c43
<     for cats in Category.objects.all ():
---
>     for cats in Category.objects.all().order_by('name'):

- Loe Spee
category_display.py.patch

John Shaffer

unread,
Sep 18, 2007, 11:35:41 AM9/18/07
to satchm...@googlegroups.com
The idea is good.

You'll get better results with "diff -u" or "svn diff".

Bruce Kroeze

unread,
Sep 18, 2007, 11:39:15 AM9/18/07
to satchm...@googlegroups.com
Shouldn't that be done on the model with sort=['name']?

Loe Spee

unread,
Sep 18, 2007, 12:57:08 PM9/18/07
to satchm...@googlegroups.com
John, thanks for the tips about diff, I am pretty new in the universe of patching, so thanks. I hope I did it correct this time.
Bruce, you are absolutely right I didn't think about it, the best would be indeed to add:
ordering=['name']          # see http://www.djangoproject.com/documentation/model-api/#ordering

I created a patch for this it should be applied to product/models.py.

- Loe Spee
models.py.patch

David Reynolds

unread,
Sep 19, 2007, 4:35:20 AM9/19/07
to satchm...@googlegroups.com

On 18 Sep 2007, at 4:35 pm, John Shaffer wrote:

>
> The idea is good.
>
> You'll get better results with "diff -u" or "svn diff".

.. and saving the diff into a file, creating a ticket for it and
attaching it to the ticket ;)


--
David Reynolds
da...@reynoldsfamily.org.uk


Loe Spee

unread,
Sep 19, 2007, 5:59:59 AM9/19/07
to satchm...@googlegroups.com
On 9/19/07, David Reynolds <da...@reynoldsfamily.org.uk> wrote:

.. and saving the diff into a file, creating a ticket for it and
attaching it to the ticket ;)


Consider it done ;), http://www.satchmoproject.com/trac/ticket/162 .

- Loe Spee
Reply all
Reply to author
Forward
0 new messages