You could always use a proxy model instead of monkey patching.

class MyUser(User):
  class Meta:
    proxy = True
    ordering = ('first_name', 'last_name')
  def __unicode__(self):
    return self.get_full_name()

Then in any models you define a FK to User, just FK to MyUser instead.

On Fri, May 21, 2010 at 2:18 PM, <[email protected]> wrote:

> 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, e.g.:
> AUTH_DEFAULT_ORDERING = ( 'first_name', 'last_name' )

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

Reply via email to