Django

Code

Ticket #6604 (closed: fixed)

Opened 7 months ago

Last modified 4 weeks ago

Custom sort of QuerySet() as list

Reported by: Alexander Nesterov <alexanderad@gmail.com> Assigned to: nobody
Milestone: Component: Database wrapper
Version: SVN Keywords: queryset, sort
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

In my table I have values like: 'test1', 'test2', 'test111' and so on, and need to sort them. ORDER BY statement sorts them "wrongly" as strings: 'test2' > 'test4' - false but 'test4' > 'test12' - true. I can sort this values manually, using list and custom cmp function, but in this situation my sort function will return list instead of QuerySet? object, that I need for my ModelChoiceField?. Is there any way to sort QuerySet? items as list? (list.sort(cmp=...)) Thanks.

Attachments

Change History

02/14/08 05:43:18 changed by mtredinnick

  • status changed from new to closed.
  • needs_better_patch changed.
  • resolution set to invalid.
  • needs_tests changed.
  • needs_docs changed.

Please ask questions like this on the django-users list, not in the bug reporting system.

06/24/08 14:44:32 changed by lukeplant

  • resolution changed from invalid to fixed.

(In [7736]) newforms-admin: Fixed #6604 - removed useless code. Thanks Petr Marhoun, programmerq

06/24/08 15:05:17 changed by lukeplant

Oops, typo in commit message accidentally closed this. mea culpa.

06/24/08 16:29:23 changed by CollinAnderson

([7736] actually closed #6004)

08/01/08 13:48:01 changed by slinkp

For anyone who finds this bug while searching for a way to solve the problem, see this thread for a solution: http://groups.google.com/group/django-users/browse_thread/thread/341926c0daf90862


Add/Change #6604 (Custom sort of QuerySet() as list)




Change Properties
Action