#13914: Add natural keys to contrib.auth.User and Group models
-------------------------------------+-------------------------------------
Reporter: jbochi | Owner: aaugustin
Type: New feature | Status: new
Component: contrib.auth | Version: SVN
Severity: Normal | Resolution:
Keywords: Contrib, Auth, | Triage Stage: Ready for
User, Group, natural keys | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by charettes):
Replying to [comment:25 gcc]:
> Users can retrofit this, without modifying Django source, using the
following monkey patch:
>
> {{{
>
> from django.contrib.auth import models as auth_models
> from django.db import models as db_models
> class GroupManagerWithNaturalKey(db_models.Manager):
> def get_by_natural_key(self, name):
> return self.get(name=name)
> auth_models.Group.objects = GroupManagerWithNaturalKey()
> def group_natural_key(self):
> return (self.name)
> auth_models.Group.natural_key = group_natural_key
> }}}
I think you might want to return a tuple in {{{ group_natural_key }}}.
{{{
def group_natural_key(self):
return (self.name,)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/13914#comment:26>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" 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-updates?hl=en.