Re: ordering a model on multiple fields?

2010-07-15 Thread Ben Atkin
I spoke too soon! While I was writing the blog entry, I realized that due to
some fixture mistake, I hadn't shuffled the data that I was sorting, so it
was sorted properly without my help! I fixed the glaring mistake, and then
realized that column sorting isn't applied by
django.contrib.admin.ModelAdmin, but by
django.contrib.admin.views.main.ChangeList. I subclassed ChangeList, and
made the ModelAdmin use the subclassed ChangeList by overriding the
get_changelist() method, and I'm pretty sure it's working now.

http://github.com/benatkin/tuneage/blob/master/tunes/admin.py

Ben

On Thu, Jul 15, 2010 at 9:07 PM, Ben Atkin  wrote:

> I have a solution for you:
>
> http://github.com/benatkin/tuneage/blob/master/tunes/admin.py
>
> I'm going to post a blog entry to http://python-web.blogspot.com/explaining 
> my code, but it might take a little while. In the meantime, let
> me know if you need any help understanding the code, or run into any issues.
>
> Ben
>
>
> On Thu, Jul 15, 2010 at 7:15 AM, Scott Gould  wrote:
>
>> The Django *admin* only uses one field, ever.
>>
>> Bit of an irritating limitation, I grant you, but with the use of date
>> hierarchies and list filters it's not too bad.
>>
>> On Jul 14, 7:40 pm, hjebbers  wrote:
>> > is there a way to have a model class sorted on multiple fields?
>> > in the meta class of my models I set the ordering, but django uses
>> > only the first field for ordering;
>> > a second field is just ignored.
>> >
>> > (I am aware that if a users starts to sort using table headers in the
>> > admin interface only one field will be used. It would just be great to
>> > have the initial ordering on 2 fields.)
>> >
>> > kind regards, henk-jan ebbers
>>
>> --
>> 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.
>>
>>
>

-- 
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.



Re: ordering a model on multiple fields?

2010-07-15 Thread Ben Atkin
I have a solution for you:

http://github.com/benatkin/tuneage/blob/master/tunes/admin.py

I'm going to post a blog entry to http://python-web.blogspot.com/ explaining
my code, but it might take a little while. In the meantime, let me know if
you need any help understanding the code, or run into any issues.

Ben

On Thu, Jul 15, 2010 at 7:15 AM, Scott Gould  wrote:

> The Django *admin* only uses one field, ever.
>
> Bit of an irritating limitation, I grant you, but with the use of date
> hierarchies and list filters it's not too bad.
>
> On Jul 14, 7:40 pm, hjebbers  wrote:
> > is there a way to have a model class sorted on multiple fields?
> > in the meta class of my models I set the ordering, but django uses
> > only the first field for ordering;
> > a second field is just ignored.
> >
> > (I am aware that if a users starts to sort using table headers in the
> > admin interface only one field will be used. It would just be great to
> > have the initial ordering on 2 fields.)
> >
> > kind regards, henk-jan ebbers
>
> --
> 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.
>
>

-- 
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.



Re: ordering a model on multiple fields?

2010-07-15 Thread Scott Gould
The Django *admin* only uses one field, ever.

Bit of an irritating limitation, I grant you, but with the use of date
hierarchies and list filters it's not too bad.

On Jul 14, 7:40 pm, hjebbers  wrote:
> is there a way to have a model class sorted on multiple fields?
> in the meta class of my models I set the ordering, but django uses
> only the first field for ordering;
> a second field is just ignored.
>
> (I am aware that if a users starts to sort using table headers in the
> admin interface only one field will be used. It would just be great to
> have the initial ordering on 2 fields.)
>
> kind regards, henk-jan ebbers

-- 
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.



ordering a model on multiple fields?

2010-07-14 Thread hjebbers
is there a way to have a model class sorted on multiple fields?
in the meta class of my models I set the ordering, but django uses
only the first field for ordering;
a second field is just ignored.

(I am aware that if a users starts to sort using table headers in the
admin interface only one field will be used. It would just be great to
have the initial ordering on 2 fields.)

kind regards, henk-jan ebbers

-- 
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.