Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Unsorted user selection widget after changeset 7806 (nfa)
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
spacetaxi  
View profile  
 More options Jul 3 2008, 7:56 am
From: spacetaxi <spacet...@gmail.com>
Date: Thu, 3 Jul 2008 04:56:14 -0700 (PDT)
Local: Thurs, Jul 3 2008 7:56 am
Subject: Unsorted user selection widget after changeset 7806 (nfa)
Hello, currently I'm a little bit lost on this one... Maybe some kind
soul can give me a hint?

Look at this excerpt of a model class:

-----
from django.db import models
from django.contrib.auth.models import User
class Article(models.Model):
    # (...snip...)
    editors = models.ManyToManyField(User,
related_name='articles_from_editor')
    # (...snip...)
-----

Everything was fine up to changeset 7806, which removed the default
ordering of the User class:
http://code.djangoproject.com/changeset/7806

After changeset 7806 the user selection widget in the admin form for
my Article class contains *unsorted* usernames. This is a major
problem when there are a lot of users existing in the database...

So what's the easiest and most elegant way to get the user selection
widget sorted again?

BTW, I'm using the newforms-admin branch.

TIA
-Stephan


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
spacetaxi  
View profile  
 More options Jul 4 2008, 9:21 am
From: spacetaxi <spacet...@gmail.com>
Date: Fri, 4 Jul 2008 06:21:46 -0700 (PDT)
Local: Fri, Jul 4 2008 9:21 am
Subject: Re: Unsorted user selection widget after changeset 7806 (nfa)
Hm, it seems to me that nobody has a solution? Do I have to replace
the many-to-many-relation (editors) with an additional ArticleEditor-
class, containting a one-to-many relation to the User class and a one-
to-many relation to Article? Is this the only way to get a sorted User
selection widget?

Kind regards
-Stephan

On 3 Jul., 13:56, spacetaxi <spacet...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Karen Tracey  
View profile  
 More options Jul 4 2008, 9:52 am
From: "Karen Tracey" <kmtra...@gmail.com>
Date: Fri, 4 Jul 2008 09:52:47 -0400
Local: Fri, Jul 4 2008 9:52 am
Subject: Re: Unsorted user selection widget after changeset 7806 (nfa)

On Fri, Jul 4, 2008 at 9:21 AM, spacetaxi <spacet...@gmail.com> wrote:
> Hm, it seems to me that nobody has a solution? Do I have to replace
> the many-to-many-relation (editors) with an additional ArticleEditor-
> class, containting a one-to-many relation to the User class and a one-
> to-many relation to Article? Is this the only way to get a sorted User
> selection widget?

You've waited one day right at the beginning of a big holiday weekend in the
US; I'd guess rather that no one has had a chance to look into this yet.  If
you want to make sure it doesn't get lost, open a ticket for it, but it's a
bit early I think to be concluding you need to restructure your application
to get around the change.

Karen


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
spacetaxi  
View profile  
 More options Jul 4 2008, 10:24 am
From: spacetaxi <spacet...@gmail.com>
Date: Fri, 4 Jul 2008 07:24:21 -0700 (PDT)
Local: Fri, Jul 4 2008 10:24 am
Subject: Re: Unsorted user selection widget after changeset 7806 (nfa)
On 4 Jul., 15:52, "Karen Tracey" <kmtra...@gmail.com> wrote:

> You've waited one day right at the beginning of a big holiday weekend in the
> US; [...]

Ooops, sorry. I didn't think about this. Thanks for your feedback!

-Stephan


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
spacetaxi  
View profile  
 More options Jul 24 2008, 3:22 am
From: spacetaxi <spacet...@gmail.com>
Date: Thu, 24 Jul 2008 00:22:49 -0700 (PDT)
Local: Thurs, Jul 24 2008 3:22 am
Subject: Re: Unsorted user selection widget after changeset 7806 (nfa)
On 3 Jul., 13:56, spacetaxi <spacet...@gmail.com> wrote:

As I didn't get any feedback on this one, I finally managed to find a
solution on my own. Maybe it'll be helpful for somebody out there.

I define an ArticleAdmin class (newforms-admin) overriding the
get_form method:
-----
class ArticleAdmin(admin.ModelAdmin):
    def get_form(self, request, obj=None):
        f = super(CVAdmin, self).get_form(request, obj)
        qs = f.base_fields['editors'].queryset
        f.base_fields['editors'].queryset = qs.order_by('username')
        return f

admin.site.register(Article, ArticleAdmin)
-----
I don't know if this is the best possible solution... but it
works. ;-)

Kind regards
-Stephan

PS: This also applies to http://groups.google.com/group/django-users/msg/8193091b10d039c9


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
spacetaxi  
View profile  
 More options Jul 24 2008, 4:03 am
From: spacetaxi <spacet...@gmail.com>
Date: Thu, 24 Jul 2008 01:03:31 -0700 (PDT)
Local: Thurs, Jul 24 2008 4:03 am
Subject: Re: Unsorted user selection widget after changeset 7806 (nfa)
Ooops, I made a little mistake (copy&paste... *g*):

On 24 Jul., 09:22, spacetaxi <spacet...@gmail.com> wrote:

> -----
> class ArticleAdmin(admin.ModelAdmin):
>     def get_form(self, request, obj=None):
>         f = super(CVAdmin, self).get_form(request, obj)

The above line must look like this:
        f = super(ArticleAdmin, self).get_form(request, obj)

>         qs = f.base_fields['editors'].queryset
>         f.base_fields['editors'].queryset = qs.order_by('username')
>         return f

> admin.site.register(Article, ArticleAdmin)
> -----

Kind regards
-Stephan

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »