Starting webserver using your first simple Django project

As you are here, it means you are ready to get started with your first django project. This post is all about this. In this post, we will show you how to create first simple ( default ) django project and start it as a webserver.

$ mkdir django_container
$ cd django_container
$ python3 -m venv env

Note: You can set any directory for virtual environment, lets say we want to create environment in current directory, then you can use above command but if you want create environment in “/home/devlab/virtualenvs” directory, the above command will be “python3 -m venv /home/devlab/virtualenvs”

$ source env/bin/activate 
(env) $ pip install django

Now, we have all the setup done and we are ready to start our first django project, which can be started using simple command as below,

$ django-admin startproject my_django_project .

Notice: the dot ( . ) at the end of command. Above command, initialised everything you need for your first django project, as you can see below,

$ ls
env  my_django_project
$ tree my_django_project/

Now, we need to make sure our database is ready for the server, which can be intialised using “ migrate” command as,

$ python migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... 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 auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying sessions.0001_initial... OK

As we can see, now database “db.sqlite3” will be created with default tables.

$ ls
db.sqlite3  env  my_django_project

Now, lets start the server,

$ python runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
June 06, 2020 - 17:14:16
Django version 3.0.7, using settings 'my_django_project.settings'
Starting development server at
Quit the server with CONTROL-C.

As we can see now, server is started with binding to your local loopback IP address and default port as,

Starting development server at

Now, it we want to change the IP address and Port where you need to start the server, it can be done as,


here, you may get an error like “Solved: Django error Invalid HTTP_HOST header: ‘’. You may need to add ‘’ to ALLOWED_HOSTS.” refer the post to change ALLOWED_HOSTS from your projects/

Related :   Solved: Django makemigrations "No changes detected"

Finally, you are ready with your first django project and the webserver is up and running which you can verify by visiting and you should see the page as below,

django project

For writing the Django application, visit “Writing first Django Application”


Subscribe with Valid Email Id to receive updates in Inbox. ( Secured by Google FeedBurner )


3 thoughts on “Starting webserver using your first simple Django project”

Leave a Comment

Android Android Applications Android Build system Android Commands Application Libraries Application Stack / User Interface Bash / Shell Scripts Bluetooth driver Cloud Technologies Commands and Packages Compilation Content Management System Core Kernel C Programs Development & Build Development, Debugging and Performance Tools Development Environment Setup Django & REST Api Errors & Failures Git Hardware Platforms HTML JAVA Programs Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Multimedia Audio, Video, Images NDK / Middleware / HAL OS Concepts PHP Programming Languages Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Source Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Web design and development Website Hosting Wordpress Yocto / Bitbake / Openembedded