In this tutorial, you will learn how to develop a web application with Django. The first part includes the steps to install the basic tools for application development.

0. Github repository of the project

 1. Project creation

$ mkdir myprojectdir
$ cd myprojectdir
$ virtualenv myenv
$ source myenv/bin/activate
$ (myenv) pip install django
$ (myenv) django-admin startproject mysite .
$ (myenv) django-admin startapp blogs .

 2. Project configuration


    'blogs', # new

 3. Creating a view

In add the following code :


from django.shortcuts import render
from django.http import HttpResponse

def index(request):
    return HttpResponse("Hello world !")

 4. Creating an url file 

In the blogs application directory create a new file named and add the following code to it


from django.urls import path
from . import views

urlpatterns = [
    path('', views.index, name='index')

 5. Add the application urls to the url patterns of the project

Add the following code in the file of the mysite directory


from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('blog/', include('blogs.urls')),

6. Start the server

python runserver

7. Go to the browser

Insert the localhost address :

0 comment

There are no comments yet.

Log in to leave a reply

Related posts

Developing a Web Application with Django Part 2: Templates


Developing a Web Application with Django Part 3 : Models


Learn Python by Example | Basics