user = User.objects.create_user('john', 'lennon@thebeatles.com', 'johnpassword') user.is_staff=True user.save()
Here is what the above code is Doing:
1. Creating a new User object with the username ‘john’.
2. Setting the email address to ‘lennon@thebeatles.com’.
3. Setting the password to ‘johnpassword’.
4. Saving the User object into the database so it is persisted.
5. Setting the is_staff attribute on our new user object to True.
6. Saving the changes to the database.