Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[1.0.X]: Fixed #8140 -- Made `UserManager.create_superuser` return th…

…e new `User` object, based on patch from ericholscher.

Backport of r10217 from trunk.


git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10218 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 3543e128df87abd31816f6914503c3b9621d0388 1 parent 546d764
@gdub gdub authored
View
1  django/contrib/auth/models.py
@@ -120,6 +120,7 @@ def create_superuser(self, username, email, password):
u.is_active = True
u.is_superuser = True
u.save()
+ return u
def make_random_password(self, length=10, allowed_chars='abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'):
"Generates a random password with the given length and given allowed_chars"
View
13 django/contrib/auth/tests/basic.py
@@ -24,6 +24,8 @@
False
>>> u.is_active
True
+>>> u.is_superuser
+False
>>> a = AnonymousUser()
>>> a.is_authenticated()
@@ -32,11 +34,22 @@
False
>>> a.is_active
False
+>>> a.is_superuser
+False
>>> a.groups.all()
[]
>>> a.user_permissions.all()
[]
+# superuser tests.
+>>> super = User.objects.create_superuser('super', 'super@example.com', 'super')
+>>> super.is_superuser
+True
+>>> super.is_active
+True
+>>> super.is_staff
+True
+
#
# Tests for createsuperuser management command.
# It's nearly impossible to test the interactive mode -- a command test helper
Please sign in to comment.
Something went wrong with that request. Please try again.