Re: Django tutorial part 1 (Using the api, p.choice_set.all() displays choices in reverse order)

2013-06-18 Thread Dandall Von
Thanks for succinctly educating me on this matter.  I thought it was a 
quirk but now I know.

On Tuesday, June 18, 2013 5:11:07 AM UTC-7, Jani Tiainen wrote:
>
> On Mon, 17 Jun 2013 21:34:00 -0700 (PDT) 
> Dandall Von  wrote: 
>
> > I have successfully setup Django with postgreSQL and everything is fine 
> > except for a minor problem. 
> > 
> > One the very last section of the the tutorial part 1 where we type 
> > p.pchoice_set.all(), it displays the 
> > choices in the reverse order.   
> > 
> > For example I get: Just hacking again, The sky, Not much 
> > Instead of: Not much, The sky, Just hacking again 
> > 
> > I typed it in the order it shows and still I get a reverse order. 
> > 
> > Any ideas? 
>
> That is how databases do work. 
>
> Default ordering is "no ordering". So you get results in no particular 
> order. 
>
> To have consistent fixed ordering you need to tell it somehow to database 
> backend, in Django it's done by .order_by() [1] 
>
> And then you have to select field you sort by. In case of tutorial there 
> is not actually any good field to sort by in Choice-model. 
>
>
> [1] https://docs.djangoproject.com/en/1.5/ref/models/querysets/#order-by 
> -- 
>
> Jani Tiainen 
>
> "Impossible just takes a little longer" 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Django tutorial part 1 (Using the api, p.choice_set.all() displays choices in reverse order)

2013-06-18 Thread Jani Tiainen
On Mon, 17 Jun 2013 21:34:00 -0700 (PDT)
Dandall Von  wrote:

> I have successfully setup Django with postgreSQL and everything is fine 
> except for a minor problem.
> 
> One the very last section of the the tutorial part 1 where we type 
> p.pchoice_set.all(), it displays the
> choices in the reverse order.  
> 
> For example I get: Just hacking again, The sky, Not much
> Instead of: Not much, The sky, Just hacking again
> 
> I typed it in the order it shows and still I get a reverse order.
> 
> Any ideas?

That is how databases do work.

Default ordering is "no ordering". So you get results in no particular order.

To have consistent fixed ordering you need to tell it somehow to database 
backend, in Django it's done by .order_by() [1]

And then you have to select field you sort by. In case of tutorial there is not 
actually any good field to sort by in Choice-model.


[1] https://docs.djangoproject.com/en/1.5/ref/models/querysets/#order-by
-- 

Jani Tiainen

"Impossible just takes a little longer"

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Django tutorial part 1 (Using the api, p.choice_set.all() displays choices in reverse order)

2013-06-18 Thread Dandall Von
I have successfully setup Django with postgreSQL and everything is fine 
except for a minor problem.

One the very last section of the the tutorial part 1 where we type 
p.pchoice_set.all(), it displays the
choices in the reverse order.  

For example I get: Just hacking again, The sky, Not much
Instead of: Not much, The sky, Just hacking again

I typed it in the order it shows and still I get a reverse order.

Any ideas?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.