01
02
Introduction to Django
Lets start
01
02
04
Rapid development
High-level Python web framework
03 Less code
01
02 Multilingual Support
Object-Relational Mapping (ORM) Support
03 Framework Support
04 Administration GUI
05 Development Environment
Step-1
q Open your browser and go www.python.org
q Underneath the heading at the top that says Python Releases for Windows, click
on the link for the Latest Python 3 Release - Python 3.x.x.
q Scroll to the bottom and select either Windows x86-64 executable installer for 64-
bit or Windows x86 executable installer for 32-bit.
Step-2 Run the Installer
Once you have chosen and downloaded an installer, simply run it by double-clicking on
the downloaded file. A dialog should appear that looks something like this:
Go to the Command Prompt
pip install django
Go to the Command Prompt
python -m django --version
django-admin startproject project name
myproject/
manage.py
myproject/
__init__.py
settings.py
urls.py
wsgi.py
python manage.py runserver
python manage.py startapp
Application Name
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def hi(request):
return HttpResponse('<h1>Welcome to Django Project</h1>')
At first you have to be create a urls.py file in your app
from django.urls import path
from . import views #import the view
urlpatterns = [
path('', views.hi,name='Home-page'),
path(‘about', views.about,name=‘About-page'),
]
Add your app url in your project
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('myapp.urls'))
]
python manage.py runserver
1. Create templates directory into your app
2. Create another directory into the templates direct
ory as per your app name.
3. Create a .html file
1. Open settings.py
2. Install the apps
INSTALLED_APPS = [
'myapp.apps.MyappConfig',
]
def hi(request):
return render(request,'myapp/hi.html')
def hi(request):
return render(request,'myapp/hi.html')
q Aside from the HTML generated by the server, web applications generally need to ser
ve additional files — such as images, JavaScript, or CSS — necessary to render the
complete web page. In Django, we refer to these files as “static files”.
First, create a directory called static in your myapp directory.
Django will look for static files there, similarly to how Django finds
templates inside myapp/templates/
First, create a directory called static in your myapp directory.
Django will look for static files there, similarly to how Django finds
templates inside myapp/templates/
Within the static directory you have just created, create another
directory called myapp and within that create a file called style.css.
In other words, your stylesheet should be at myapp/static/myapp/
style.css.
Because of how the AppDirectoriesFinder staticfile finder works,
you can refer to this static file in Django as myapp/style.css, similar
to how you reference the path for templates.
{%load static %}
<link rel="stylesheet" type="text/css" href="{% static ‘myapp/style.css' %}">
Thank You

Django is a high-level Python web framework that enables rapid development of secure and scalable web applications.