Setting up Database for Django project and running Server(Part III)

In this tutorial, we are going to learn how to set up the database for your Django project and run it in your browser using your computer as a local server.

Link to the Previous tutorial: How to create your Django project and modify its settings. (Part II)

Tutorial series on creating a basic Blog Application using Django

Setting up a Database for Django

There are many different database software available for managing data/information for your web application. In this project, we are going to use the default one


This database is already there in site1/  ([project_name]/

    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),

To create a database, open a Terminal/Console in the same directory as containing and run :

python migrate

If everything goes well, you should see something like this.


Operations to perform:
  Apply all migrations: auth, admin, contenttypes, sessions
Running migrations:
  Rendering model states... DONE
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying sessions.0001_initial... OK

The database is set now. Now time to start the web server.

Starting the web server in Django

To start the web server using your machine as Local Server, use the command:

From Windows:

python runserver 0:8000

From Linux/ Mac OS:

python runserver

That’s it! Now you finally have a running website on your local machine.

set up database and start server in Django

To stop the web server, switch back to the window in which it’s running and press CTRL+C – Control and C keys together (on Windows, you might have to press Ctrl+Break).

Feel free to drop any doubts regarding anything in the procedure.

Next Part of this tutorial series:

Creating Django Application and Introduction to Django Models(Part IV)


Also, have a look at :

Introduction to Django Framework and How to install it? (Part I)

How to create your Django project and modify its settings. (Part II)

Leave a Reply

Your email address will not be published. Required fields are marked *