#25009: create_user(..., is_staff=True) raises TypeError multiple values for
keyword argument 'is_staff'
------------------------------+------------------------------------
     Reporter:  allcaps       |                    Owner:  nobody
         Type:  Bug           |                   Status:  new
    Component:  contrib.auth  |                  Version:  1.8
     Severity:  Normal        |               Resolution:
     Keywords:                |             Triage Stage:  Accepted
    Has patch:  0             |      Needs documentation:  0
  Needs tests:  0             |  Patch needs improvement:  0
Easy pickings:  1             |                    UI/UX:  0
------------------------------+------------------------------------

Comment (by allcaps):

 Seems like we can have a cheeseburger without cheese :). Forgiveness is
 cool. But we can also raise an error for the superuser.

 {{{
 def create_user(self, username, email=None, password=None,
 **extra_fields):
     extra_fields.setdefault('is_staff', False)
     extra_fields.setdefault('is_superuser', False)
     return self._create_user(username, email, password, **extra_fields)

 def create_superuser(self, username, email, password, **extra_fields):
     if extra_fields.has_key('is_staff') and extra_fields.get('is_staff')
 is False:
         raise ValueError('Superuser needs to be staff. Do not set
 `is_staff`.')
     if extra_fields.has_key('is_superuser') and
 extra_fields.get('is_superuser') is False:
         raise ValueError('Superuser needs to be superuser. Do not set
 `is_superuser`.')
     extra_fields.setdefault('is_staff', True)
     extra_fields.setdefault('is_superuser', True)
     return self._create_user(username, email, password, **extra_fields)
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25009#comment:2>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.0c468bf8b1715dce75b4c8f5de8bd60b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to