#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 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
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/13914#comment:25>
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 django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to