Now we are going to put data in database. For this we are going use the Django shell to put data in our database. In this blog i will show you how to access the Shell in order to connect to the database,store and update the data.

Make sure your virtual environment activated and your with in the folder file.Lets look at how to create user for Django using interactive console

Now Let’s create a Simple project in Django . If you do not know how to create the basic project refer the blog

Or you can import the project from Github

Github link :

Creating Superuser in Django

Now we are going to create a super user by following command

python createsuperuser

On executing above command we can get this Output as Show below asking for some neccessary things and give those to go further

Note : Password entered in the terminal is invisible

Let’s start the server and log in using the admin URL (make sure path(‘admin/’,,is mentioned in the URL patterns).

After loging in with user name and password and Clicking on users we can get the following output

Lets Create users in the users file using Django shell

Django Shell

We can run Django Interactive shell by using this command

python shell

you will get similar output as 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('user','[email protected]','[email protected]')

On refreshing the tab we can get our output sharing the screenshot below

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

GitHub link :