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 manage.py 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 https://studygyaan.com/django/how-do-i-customize-django-404-error-page

Or you can import the project from Github

Github link : https://github.com/saikumar248/404_error_page-customization

Creating Superuser in Django

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

python manage.py 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/’, admin.site.urls),is mentioned in the URL patterns).

http://127.0.0.1:8000/admin/

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 manage.py 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]')
user.save()

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 : https://github.com/saikumar248/404_error_page-customization