Changes between Initial Version and Version 1 of Ticket #25009, comment 2
- Timestamp:
- Jun 19, 2015, 6:09:21 PM (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #25009, comment 2
initial v1 1 1 Seems like we can have a cheeseburger without cheese :). Forgiveness is cool. But we can also raise an error for the superuser. 2 2 3 {{{ 3 {{{#!python 4 4 def create_user(self, username, email=None, password=None, **extra_fields): 5 5 extra_fields.setdefault('is_staff', False) … … 8 8 9 9 def create_superuser(self, username, email, password, **extra_fields): 10 if extra_fields.has_key('is_staff') and extra_fields.get('is_staff') is False:11 raise ValueError('Superuser needs to be staff. Do not set `is_staff`.')12 if extra_fields.has_key('is_superuser') and extra_fields.get('is_superuser') is False:13 raise ValueError('Superuser needs to be superuser. Do not set `is_superuser`.')14 10 extra_fields.setdefault('is_staff', True) 15 11 extra_fields.setdefault('is_superuser', True) 12 if extra_fields.get('is_staff') is False: 13 raise ValueError('Superuser needs to be staff. Do not set is_staff.') 14 if extra_fields.get('is_superuser') is False: 15 raise ValueError('Superuser needs to be superuser. Do not set is_superuser.') 16 16 17 return self._create_user(username, email, password, **extra_fields) 17 18 }}}