Create simple hello world application in Django

At first check out how to install Django!

After install django, create a project file name MyFristApp. Type this command on terminal django-admin startproject MyFirstApp

Creat Project


Then create App. Type cd MyFirstApp for getting into this folder then create django-admin startapp MyApp


Create App


Now In this MyApp folder you can see file. Go there and type from django.http import HttpResponse



Under that line we create an index with function like this


def index(request):
    return HttpResponse("<em>My First App</em><br>Voila! i have done it!")


create index function with html code!

Caution! You should maintain the indent line like in the photo

Now we need to link this file to our file. How we do that? Go to MyFirstApp folder, there you can find the file. Open it and find the line urlpatterns



Above this urlpatterns line we should import our MyApp from Myapp import views  and then link it into urlpatterns.  path(‘ ‘,views.index,name=’index’),


import our app and link it


And finally We need to edit our to let the actual project know that MyApp application actually exists. to do that go there and find INSTALLED_APPS line. In that line, we input our MyApp like the photo below



Now everythings is set and saved. Go the terminal and type python runserver then hit enter




Now go to the browser and type the url VOILA! You CREATED THE FIRST APP IN DJANGO!