Django Order_by blank?

For your case, I think you should do the sorting in your python code (currently, as it is, the sorting is made in the database). It is not possible, imho, to do what you want in the db, at least without writing some sql by hand.

For your case, I think you should do the sorting in your python code (currently, as it is, the sorting is made in the database). It is not possible, imho, to do what you want in the db, at least without writing some sql by hand. So the idea would be to do something like this in your view : your_objects = list(YourObject.objects.

Filter(....)) your_objects. Sort(key=lambda ob: ob. Title_french if ob.

Title_french else ob. Title) As long as you sort small lists, this should not be a too problematic performance issue.

Its not possible in django", thats what I wanted to know, plus thank for the alternative solution - it looks neat! – Mark Sep 1 '10 at 8:16.

Have you tried ordering by multiple fields (doc): ordering = ('title_french', 'title').

Specify both the columns, title_french and title in order_by queryset. Order_by('title_french', 'title') title_french will be given first preference and if there are two entries with the same title_french then those two entries will be sorted by their title.

This will order both the English and Frech, however, since the Frech has a lot of blanks all the English come first. I want my ordering to have all the non-blank frech first, then the English, or just everything english/french A-Z – Mark Aug 31 '10 at 13:02.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions