You can't use a dictionary if you expect a certain order of key/value pairs.

Given model A you could get a list of field objects in the same order (I
think) as defined in the model class

A._meta.fields

At least with that information you could programatically produce a list of
data in matching order with a little code.

On Fri, Aug 6, 2010 at 1:34 PM, owidjaya <owidj...@gmail.com> wrote:

> is there a way that i can get the a list of dictionaries as a result
> with the dictionary having the same field order as the table?
>
> On Aug 6, 10:18 am, Daniel Roseman <dan...@roseman.org.uk> wrote:
> > On Aug 6, 6:08 pm, owidjaya <owidj...@gmail.com> wrote:
> >
> > > I checked it and the field order still not the same.
> > > Just to clarify. I want the to do this A.objects.all().values()
> > > and still get the each list in the result to have the same "field
> > > order" as the database table defined.
> >
> > `values()` returns a set of dictionaries. Dictionaries are unordered
> > by definition.
> >
> > `values_list()` returns a set of tuples, which should be in the same
> > order as the model definition, however you don't get the fieldnames.
> > --
> > DR.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.

Reply via email to