My favourite workaround for this is to register a small dummy apps
overriding default properties:
from django.conf import settings
if "django.contrib.auth" in settings.INSTALLED_APPS:
# modify User model properties only if contrib.auth is installed
from django.contrib.auth.models import User
# display full name instead of user name where string representation is
required:
User.__unicode__ = lambda self: self.get_full_name()
# set default ordering by first name and last name:
User._meta.ordering = ['first_name', 'last_name']
This will globally modify default sorting (and unicode representation) for
User model. It is usually the first thing I put into my project.
This is a bit of hard coded to cater to my specific requirements (in many
cases I do have first and last names). A more flexible workaround could
involve special settings, eg:
AUTH_DEFAULT_ORDERING = ( 'first_name', 'last_name' )
On , Karen Tracey <[email protected]> wrote:
On Fri, May 21, 2010 at 8:46 AM, Jeremy Dunck [email protected]> wrote:
Even so, you could create a custom ModelAdmin for User, specifying the
ordering option:
http://docs.djangoproject.com/en/1.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.ordering
The default model admin for the User model already specifies ordering by
username. The issue, I believe, is that that does not affect things like
ForeignKey drop-down boxes.
Karen
--
You received this message because you are subscribed to the Google
Groups "Django developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=en.
--
You received this message because you are subscribed to the Google Groups "Django
developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=en.