Skip to content
Related Articles
Get the best out of our app
Open App

Related Articles

How to create user from Django shell

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Let’s look at how to create a user for Django using Django’s interactive shell? Make sure you have the virtual environment activated, and you are within the folder that has the file. 

Note: Refer to the article How to Create a Basic Project using MVT in Django? to understand how to create a project in Django.

Let’s launch Django’s interactive shell using the below command

python shell

You will get a similar output as mentioned below

Now enter the following code in the shell to create a user for Django.


from django.contrib.auth.models import User
user = User.objects.create_user('sonu','','sn@pswrd')

Let’s check our new user using superuser credentials. You can follow How to create superuser in Django? to create a superuser. Let’s start the server and log in using the admin URL (make sure path(‘admin/’,, is mentioned in the URL patterns).

Sharing the screenshot below

You can check the newly added user details under the Users section. 

My Personal Notes arrow_drop_up
Last Updated : 14 Sep, 2021
Like Article
Save Article
Similar Reads
Related Tutorials