SlideShare a Scribd company logo
DJANGO 
-Harmeet
What is Django? 
Django is a python-based web 
framework.
What is a framework? 
A web application framework (WAF) is a 
software framework that is designed to support 
the development of dynamic websites, web 
applications, web services and web resources.
The MTV Design 
 M-Models 
 T-Templates 
 V-View
Creating a Project 
Move to the directory where you want to create the project 
Type the following command in terminal 
C:/Python27/Scripts/django-admin.py startproject myprojectname 
Mysite/ 
manage.py 
mysite/ 
__init__.py 
settings.py 
urls.py 
wsgi.py
Settings.py 
 Databases 
DATABASES = { 
'default': { 
'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'mysql', 
'sqlite3' or 'oracle'. 
'NAME': '', # Or path to database file if using sqlite3. 
'USER': '', # Not used with sqlite3. 
'PASSWORD': '', # Not used with sqlite3. 
'HOST': '', # Set to empty string for localhost. Not used with 
sqlite3. 
'PORT': '', # Set to empty string for default. Not used with 
sqlite3. 
} 
}
Settings.py (contd…) 
 Debug- is a boolean field and used to 
decide if your project is running on debug 
mode or not.
Creating an App 
 Move inside your project directory 
 Type the following in your terminal 
python manage.py startapp appname 
Your directory listing will look like 
books/ 
__init__.py 
admin.py 
models.py 
tests.py 
views.py
View 
 It is a python function that takes a request 
parameter as its first argument. 
 It always returns a response. 
from django.http import HttpResponse 
def hello(request): 
#Your code goes here 
return HttpResponse("Hello world")
URL(s) 
 It is used to link up your view to a URL(s) typed in the 
address bar. 
 It is a mapping between URL(s) and view functions that 
should be called for those URL(s) 
from django.conf.urls.defaults import patterns, include, url 
from mysite.views import hello 
urlpatterns = patterns('', 
url(r'^hello/$', hello), 
)
Refrences 
 https://www.djangoproject.com/ 
 https://www.djangobook.com 
 http://www.tangowithdjango.com/
Django: 
The Web framework for 
perfectionists with deadlines 
Thank you!

More Related Content

Django

  • 2. What is Django? Django is a python-based web framework.
  • 3. What is a framework? A web application framework (WAF) is a software framework that is designed to support the development of dynamic websites, web applications, web services and web resources.
  • 4. The MTV Design  M-Models  T-Templates  V-View
  • 5. Creating a Project Move to the directory where you want to create the project Type the following command in terminal C:/Python27/Scripts/django-admin.py startproject myprojectname Mysite/ manage.py mysite/ __init__.py settings.py urls.py wsgi.py
  • 6. Settings.py  Databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. 'NAME': '', # Or path to database file if using sqlite3. 'USER': '', # Not used with sqlite3. 'PASSWORD': '', # Not used with sqlite3. 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. 'PORT': '', # Set to empty string for default. Not used with sqlite3. } }
  • 7. Settings.py (contd…)  Debug- is a boolean field and used to decide if your project is running on debug mode or not.
  • 8. Creating an App  Move inside your project directory  Type the following in your terminal python manage.py startapp appname Your directory listing will look like books/ __init__.py admin.py models.py tests.py views.py
  • 9. View  It is a python function that takes a request parameter as its first argument.  It always returns a response. from django.http import HttpResponse def hello(request): #Your code goes here return HttpResponse("Hello world")
  • 10. URL(s)  It is used to link up your view to a URL(s) typed in the address bar.  It is a mapping between URL(s) and view functions that should be called for those URL(s) from django.conf.urls.defaults import patterns, include, url from mysite.views import hello urlpatterns = patterns('', url(r'^hello/$', hello), )
  • 11. Refrences  https://www.djangoproject.com/  https://www.djangobook.com  http://www.tangowithdjango.com/
  • 12. Django: The Web framework for perfectionists with deadlines Thank you!