Django is a Framework , developed by Python . It's Used to develop a Web application We can use this to Provide a Dynamic Content web Application . Like Spotify Pinterest Instagram Mozilla ................;
Step : 1 
              We Need to check That we have Installed Python on our Machine Make sure You installed on That 
        Make Sure You check Using -- PYTHON --VERSION
Installing Django On local Machine
 // Installation Djago
    
 pip install Django
  
Step : 2
We are about to create a Django Project as it was a Framework . We need to create a Project Inside we do Our work .
                python mange.py runserver -> It's used to run our Project
Create a Django Project
 // Create Project
    
djano-admin startproject name
  
Step : 3
Run our Project on Local Server Because Django has own Development environment we run using that (Local server)
           python mange.py runserver -- It's used to run our ProjectWe can also used to mention a specify port like         python manage.py runserver 4000
Write a Program to calculate Two Numbers
 // Specify Server
    
python manage.py runserver 4000
  
Step 4 :
                        We need to create a APPLICATION inside a Project , Because One project can Contain Multiple Application , So that Why ... we Create a App inside a Project
Creating a Application Inside a Project
 // Django-app
    
 python manage.py startapp test1
  
In default app we have (__init__ ,admin ,apps ,models ,tests ,views and Migratrions folders)
In default Project we have (__init__ ,asgi ,settings,urls,wsgi and db.sqllite)
Step - 5:
Getting into a Real Thing ............HELLO WORLD!
First of all we need for that to Create a urls.py File under your application folder , Beacuse we have file url.py under only project folder we need to connnect these app to project like wise we can connect Multiple Project ...
Create a URL.PY file
 // Urls.py from django.urls import path
from . import views    
  
Step : 6
                                Edit Views.py to make Print Hello World!
First of all We make this as Print Using a HTTP response ,That will be lot more Easier
Add a Function on Views
 // Views.py
    
from django.http import HttpResponse        
def home (request):
    return HttpResponse ("Hello world!")
  
Step : 7
                            We need to Map a Views.py to our url.py from APP
    This is will be a path of helloworld , in views.home we have a func
Url.py from app folder
 // url.py
    
 urlpatterns = [
    path('',views.home ,name='home')
]
  
Step : 8
                    The final Step...    Connection Between App to Project
This is a Urls file on your project already there , You can add the app urls in here to comabine a app and project
add these '' path to project , 'test1.urls is an app file  
Url.py from Project Folder
 // urls.py
urlpatterns = [
    path('',include('test1.urls')), 
    path('admin/', admin.site.urls),
]    
 
  
Step : 9
                    So far we did Will Make enough to Print Hello world!


No comments:
Post a Comment