Skip to content

Latest commit

 

History

History
48 lines (29 loc) · 1.32 KB

django.md

File metadata and controls

48 lines (29 loc) · 1.32 KB

DJANGO

  1. To start a project named mysite:
django-admin startproject mysite
  1. These files will be created when the project is created:
mysite/
    manage.py
    mysite/
        __init__.py
        settings.py
        urls.py
        asgi.py
        wsgi.py

manage.py --> lets you interact with this django project.

inner mysite directory is the actual Python package for the project.

settings.py --> all the settings and configurations for this Django project.

urls.py --> url declarations for the Django project. A table of contents for the site.

asgi.py --> An entry point for ASGI-compatible web servers.

wsgi.py --> An entry point for WSGI-compatible web servers.

  1. django-admin --> django's command line utility for administrative tasks.

  2. python3 manage.py runserver --> will run the project in browser.

  3. python3 manage.py startapp polls --> will create an app named polls.

How DJANGO processes a request ?

  1. Django determines the root URLconf module to use. This is the value of the ROOT_URLCONF setting in the settings.py. But if the incoming HTTPRequest object has a urlfconf attribute, its value wil be used in place of the ROOT_URLCONF setting.

  2. Django loads that Python module and looks for the variable urlpatterns.