Hello world !! Program in Django
In this video , You will know How to make Hello world ! program in Django in hindi
how to create views . Url
Open a terminal and move to the directory containing the django-admin file using the
cd command.In our case, the django-admin file resides on the Desktop.
Creating a project and deploying
We can create a new project using the
startproject command, followed by the name of the project (HelloWorld). This command will create a new folder with the given name of the project in the same directory. Now, once again, move into the new directory using the cd command and deploy it on the local server.In your project folder, you will have a Python file with the name manage and another folder with the name project.
After deploying it at the local server, you will get a bunch of lines on the command line interface with the server URL in it (like in the illustration above). Copy that URL to your browser and you will get an introductory message. Once you are done, press
Ctrl+c on the command line to exit from the server.Editing project to print Hello World
Now, move inside the second HelloWorld folder and create a view file using the
touch command.C:\users\educative\Helloworld\HelloWorld> touch view.py
Remember:view.pyis case-sensitive
Now, we will edit two files:
view.pyurl.py
View File
In the this file we will write the Http response and Print function.
# editing view.py file
import django.http from HttpResponse
def print(request):
return HttpResponse("Hello World!")
Url file
Once we have created our view, we will add URL configurations for our view .There will be a lot of code, so you will need to add a few lines for your print function.
# Editing url.py file
# add this command
from . import views
# add this code inside the urlpatterns
url(r'^$',view.print),
Once you are done editing those two files, run this command again:
C:\users\educative\HelloWorld> python manage.py runserver
And, yes! It prints “Hello World” when you run the URL.
Part 1 Video link : https://bit.ly/django-tutorial-part1
---------------..........-----------------
Part 2 Video Link : https://bit.ly/Django-part-2
Part 4 Video link :: https://youtu.be/dOfyNzRv5j8

Best one ❤️
ReplyDeleteWaiting for next video dear ��
ReplyDelete