Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. try:
  2. user = User.objects.get(username=username)
  3. except User.DoesNotExist:
  4. # Create a new user. Note that we can set password
  5. # to anything, because it won't be checked; the password
  6. # from settings.py will.
  7. user = User(username=username, password='get from settings.py')
  8. user.is_staff = True
  9. user.is_superuser = True
  10. user.save()
  11. return user
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement