Django tutorial
Django
i
AbouttheTutorial
Django is a web development framework that assists in building and maintaining quality
web applications. Django helps eliminate repetitive tasks making the development process
an easy and time saving experience. This tutorial gives a complete understanding of
Django.
Audience
This tutorial is designed for developers who want to learn how to develop quality web
applications using the smart techniques and tools offered by Django.
Prerequisites
Before you proceed, make sure that you understand the basics of procedural and object-
oriented programming: control structures, data structures and variables, classes, objects,
etc.
Disclaimer&Copyright
 Copyright 2015 by Tutorials Point (I) Pvt. Ltd.
All the content and graphics published in this e-book are the property of Tutorials Point (I)
Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish
any contents or a part of contents of this e-book in any manner without written consent
of the publisher.
We strive to update the contents of our website and tutorials as timely and as precisely as
possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt.
Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our
website or its contents including this tutorial. If you discover any errors on our website or
in this tutorial, please notify us at contact@tutorialspoint.com.
Django
ii
TableofContents
About the Tutorial....................................................................................................................................i
Audience..................................................................................................................................................i
Prerequisites............................................................................................................................................i
Disclaimer & Copyright.............................................................................................................................i
Table of Contents....................................................................................................................................ii
1. DJANGO – BASICS................................................................................................................1
History of Django ....................................................................................................................................1
Django – Design Philosophies..................................................................................................................1
Advantages of Django .............................................................................................................................1
2. DJANGO – OVERVIEW..........................................................................................................3
3. DJANGO – ENVIRONMENT...................................................................................................4
Step 1 – Installing Python........................................................................................................................4
Step 2 - Installing Django.........................................................................................................................4
Step 3 – Database Setup..........................................................................................................................6
Step 4 – Web Server................................................................................................................................6
4. DJANGO – CREATING A PROJECT.........................................................................................7
Create a Project.......................................................................................................................................7
The Project Structure ..............................................................................................................................7
Setting Up Your Project...........................................................................................................................8
5. DJANGO – APPS LIFE CYCLE ...............................................................................................10
6. DJANGO – ADMIN INTERFACE ...........................................................................................12
7. DJANGO – CREATING VIEWS..............................................................................................15
Django
iii
8. DJANGO – URL MAPPING ..................................................................................................17
9. DJANGO – TEMPLATE SYSTEM...........................................................................................23
The Render Function .............................................................................................................................23
Django Template Language (DTL)..........................................................................................................23
Filters....................................................................................................................................................24
Tags.......................................................................................................................................................24
10. DJANGO – MODELS ...........................................................................................................28
Creating a Model...................................................................................................................................28
Linking Models......................................................................................................................................30
11. DJANGO – PAGE REDIRECTION..........................................................................................33
12. SENDING E-MAILS..............................................................................................................36
Sending a Simple E-mail ........................................................................................................................36
Sending Multiple Mails with send_mass_mail.......................................................................................37
Sending HTML E-mail ............................................................................................................................39
Sending E-mail with Attachment...........................................................................................................41
13. DJANGO – GENERIC VIEWS................................................................................................42
14. DJANGO – FORM PROCESSING..........................................................................................46
15. DJANGO – FILE UPLOADING ..............................................................................................51
16. DJANGO – APACHE SETUP.................................................................................................55
17. DJANGO – COOKIES HANDLING.........................................................................................57
18. DJANGO – SESSIONS..........................................................................................................60
Django
iv
19. DJANGO – CACHING..........................................................................................................64
Setting Up Cache in Database................................................................................................................64
Setting Up Cache in File System.............................................................................................................65
Setting Up Cache in Memory.................................................................................................................65
Caching the Entire Site ..........................................................................................................................65
Caching a View......................................................................................................................................66
Caching a Template Fragment...............................................................................................................67
20. COMMENTS.......................................................................................................................69
21. DJANGO – RSS ...................................................................................................................74
22. DJANGO – AJAX .................................................................................................................78
Django
5
Django is a high-level Python web framework that encourages rapid development and clean,
pragmatic design. Django makes it easier to build better web apps quickly and with less code.
Note: Django is a registered trademark of the Django Software Foundation, and is licensed
under BSD License.
HistoryofDjango
 2003: Started by Adrian Holovaty and Simon Willison as an internal project at the
Lawrence Journal-World newspaper.
 2005: Released July 2005 and named it Django, after the jazz guitarist Django
Reinhardt.
 2005: Mature enough to handle several high-traffic sites.
 Current: Django is now an open source project with contributors across the world.
Django–DesignPhilosophies
Django comes with the following design philosophies:
 Loosely Coupled: Django aims to make each element of its stack independent of the
others.
 Less Coding: Less code so in turn a quick development.
 Don't Repeat Yourself (DRY): Everything should be developed only in exactly one
place instead of repeating it again and again.
 Fast Development: Django's philosophy is to do all it can to facilitate hyper-fast
development.
 Clean Design: Django strictly maintains a clean design throughout its own code and
makes it easy to follow best web-development practices.
AdvantagesofDjango
Here are few advantages of using Django which can be listed out here:
1. DJANGO – BASICS
Django
6
 Object-Relational Mapping (ORM) Support: Django provides a bridge between the
data model and the database engine, and supports a large set of database systems
including MySQL, Oracle, Postgres, etc. Django also supports NoSQL database through
Django-nonrel fork. For now, the only NoSQL databases supported are MongoDB and
google app engine.
 Multilingual Support: Django supports multilingual websites through its built-in
internationalization system. So you can develop your website, which would support
multiple languages.
 Framework Support: Django has built-in support for Ajax, RSS, Caching and various
other frameworks.
 Administration GUI: Django provides a nice ready-to-use user interface for
administrative activities.
 Development Environment: Django comes with a lightweight web server to
facilitate end-to-end application development and testing.
Django
7
As you already know, Django is a Python web framework. And like most modern framework,
Django supports the MVC pattern. First let's see what is the Model-View-Controller (MVC)
pattern, and then we will look at Django’s specificity for the Model-View-Template (MVT)
pattern.
MVC Pattern
When talking about applications that provides UI (web or desktop), we usually talk about MVC
architecture. And as the name suggests, MVC pattern is based on three components: Model,
View, and Controller. Check our MVC tutorial here to know more.
DJANGO MVC - MVT Pattern
The Model-View-Template (MVT) is slightly different from MVC. In fact the main difference
between the two patterns is that Django itself takes care of the Controller part (Software
Code that controls the interactions between the Model and View), leaving us with the
template. The template is a HTML file mixed with Django Template Language (DTL).
The following diagram illustrates how each of the components of the MVT pattern interacts
with each other to serve a user request:
The developer provides the Model, the view and the template then just maps it to a URL and
Django does the magic to serve it to the user.
2. DJANGO – OVERVIEW
Django
8
Django development environment consists of installing and setting up Python, Django, and a
Database System. Since Django deals with web application, it's worth mentioning that you
would need a web server setup as well.
Step1–InstallingPython
Django is written in 100% pure Python code, so you'll need to install Python on your system.
Latest Django version requires Python 2.6.5 or higher for the 2.6.x branch or higher than
2.7.3 for the 2.7.x branch.
If you're on one of the latest Linux or Mac OS X distribution, you probably already have Python
installed. You can verify it by typing python command at a command prompt. If you see
something like this, then Python is installed.
$ python
Python 2.7.5 (default, Jun 17 2014, 18:11:42)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2
Otherwise, you can download and install the latest version of Python from the link
http://www.python.org/download.
Step2-InstallingDjango
Installing Django is very easy, but the steps required for its installation depends on your
operating system. Since Python is a platform-independent language, Django has one package
that works everywhere regardless of your operating system.
You can download the latest version of Django from the link
http://www.djangoproject.com/download.
UNIX/Linux and Mac OS X Installation
You have two ways of installing Django if you are running Linux or Mac OS system:
 You can use the package manager of your OS, or use easy_install or pip if installed.
 Install it manually using the official archive you downloaded before.
We will cover the second option as the first one depends on your OS distribution. If you have
decided to follow the first option, just be careful about the version of Django you are installing.
3. DJANGO – ENVIRONMENT
Django
9
Let's say you got your archive from the link above, it should be something like Django-
x.xx.tar.gz:
Extract and install.
$ tar xzvf Django-x.xx.tar.gz
$ cd Django-x.xx
$ sudo python setup.py install
You can test your installation by running this command:
$ django-admin.py --version
If you see the current version of Django printed on the screen, then everything is set.
Note: For some version of Django it will be django-admin the ".py" is removed.
Windows Installation
We assume you have your Django archive and python installed on your computer.
First, PATH verification.
On some version of windows (windows 7) you might need to make sure the Path system
variable has the path the following C:Python27;C:Python27Libsite-
packagesdjangobin in it, of course depending on your Python version.
Then, extract and install Django.
c:>cd c:Django-x.xx
Next, install Django by running the following command for which you will need administrative
privileges in windows shell "cmd":
c:Django-x.xx>python setup.py install
To test your installation, open a command prompt and type the following command:
c:>django-admin.py --version
If you see the current version of Django printed on screen, then everything is set.
OR
Launch a "cmd" prompt and type python then:
Django
10
c:> python
>>> import django
>>> print django.get_version()
Django
11
End of ebook preview
If you liked what you saw…
Buy it from our store @ https://store.tutorialspoint

More Related Content

PDF
SmartDraw VP User Guide
PDF
Manual de Serviço HP DV4
PDF
Artificial neural network_tutorial
PDF
The road-to-learn-react
PDF
Netex learningMaker | Author Guide v3.2 [En]
PDF
Netex learningMaker | Author Guide v3.1 [En]
PDF
Netex learningMaker | Basic Template v1.0 [En]
PDF
726studyguide
SmartDraw VP User Guide
Manual de Serviço HP DV4
Artificial neural network_tutorial
The road-to-learn-react
Netex learningMaker | Author Guide v3.2 [En]
Netex learningMaker | Author Guide v3.1 [En]
Netex learningMaker | Basic Template v1.0 [En]
726studyguide

What's hot (19)

PDF
Netex learningMaker | Author Manual v3.0 [En]
PDF
ExTreM Expense Report Software
PDF
Quick start guide NetExplorer 6.4
PDF
Ar smartphones
PDF
Manualcamtasia
PDF
E100 manual
PDF
6 Daftar Isi
PDF
C2675m c
PDF
Java8 tutorial
DOC
Tutorial imex builder (field units)
PDF
60950106 basis-latest-till-interview-questions
PDF
Dcp 2000 field-instmanual_000344_v1_5
PDF
Open cms 8.5.1_documentation_v1.2
PDF
Sap basis r3 hand book
PDF
All view mount_instructionmanual_bw
PDF
94005 star sense_autoalign_manual_d-1
PDF
8051 flash
PDF
1152120348 1106811069manua
Netex learningMaker | Author Manual v3.0 [En]
ExTreM Expense Report Software
Quick start guide NetExplorer 6.4
Ar smartphones
Manualcamtasia
E100 manual
6 Daftar Isi
C2675m c
Java8 tutorial
Tutorial imex builder (field units)
60950106 basis-latest-till-interview-questions
Dcp 2000 field-instmanual_000344_v1_5
Open cms 8.5.1_documentation_v1.2
Sap basis r3 hand book
All view mount_instructionmanual_bw
94005 star sense_autoalign_manual_d-1
8051 flash
1152120348 1106811069manua
Ad

Similar to Django tutorial (20)

PPTX
Introduction to Django
PPTX
Unleash-the-power-of-Django.pptx
PDF
Django
PPTX
Django part 1
PDF
Step-by-Step Django Web Development with Python
PDF
Django Documentation
PDF
Django Tutorial_ Let’s take a deep dive into Django’s web framework.pdf
PDF
Introduction to Django Course For Newbie - Advance
PPTX
1-_Introduction_To_Django_Model_and_Database (1).pptx
PDF
Django in Action (MEAP V01) Christopher Trudeau
PDF
0506-django-web-framework-for-python.pdf
PDF
Django in Action (MEAP V01) Christopher Trudeau
PDF
Django Workflow and Architecture
PPTX
Django Introdcution
PDF
Learn Django Tips, Tricks & Techniques for Developers
PPTX
Django Framework Overview forNon-Python Developers
PPTX
PPTX
Introduction and features to Django.pptx
PPT
Introduction to Django
Unleash-the-power-of-Django.pptx
Django
Django part 1
Step-by-Step Django Web Development with Python
Django Documentation
Django Tutorial_ Let’s take a deep dive into Django’s web framework.pdf
Introduction to Django Course For Newbie - Advance
1-_Introduction_To_Django_Model_and_Database (1).pptx
Django in Action (MEAP V01) Christopher Trudeau
0506-django-web-framework-for-python.pdf
Django in Action (MEAP V01) Christopher Trudeau
Django Workflow and Architecture
Django Introdcution
Learn Django Tips, Tricks & Techniques for Developers
Django Framework Overview forNon-Python Developers
Introduction and features to Django.pptx
Ad

More from HarikaReddy115 (20)

PDF
Dbms tutorial
PDF
Data structures algorithms_tutorial
PDF
Wireless communication tutorial
PDF
Cryptography tutorial
PDF
Cosmology tutorial
PDF
Control systems tutorial
PDF
Computer logical organization_tutorial
PDF
Computer fundamentals tutorial
PDF
Compiler design tutorial
PDF
Communication technologies tutorial
PDF
Biometrics tutorial
PDF
Behavior driven development_tutorial
PDF
Basics of computers_tutorial
PDF
Basics of computer_science_tutorial
PDF
Basic electronics tutorial
PDF
Auditing tutorial
PDF
Artificial neural network_tutorial
PDF
Artificial intelligence tutorial
PDF
Antenna theory tutorial
PDF
Analog communication tutorial
Dbms tutorial
Data structures algorithms_tutorial
Wireless communication tutorial
Cryptography tutorial
Cosmology tutorial
Control systems tutorial
Computer logical organization_tutorial
Computer fundamentals tutorial
Compiler design tutorial
Communication technologies tutorial
Biometrics tutorial
Behavior driven development_tutorial
Basics of computers_tutorial
Basics of computer_science_tutorial
Basic electronics tutorial
Auditing tutorial
Artificial neural network_tutorial
Artificial intelligence tutorial
Antenna theory tutorial
Analog communication tutorial

Recently uploaded (20)

PDF
Journal of Dental Science - UDMY (2021).pdf
PDF
Nurlina - Urban Planner Portfolio (english ver)
PPTX
CAPACITY BUILDING PROGRAMME IN ADOLESCENT EDUCATION
PPTX
BSCE 2 NIGHT (CHAPTER 2) just cases.pptx
PDF
Environmental Education MCQ BD2EE - Share Source.pdf
PDF
Everyday Spelling and Grammar by Kathi Wyldeck
PDF
faiz-khans about Radiotherapy Physics-02.pdf
PDF
fundamentals-of-heat-and-mass-transfer-6th-edition_incropera.pdf
PPTX
Macbeth play - analysis .pptx english lit
PDF
LIFE & LIVING TRILOGY - PART - (2) THE PURPOSE OF LIFE.pdf
PDF
1.Salivary gland disease.pdf 3.Bleeding and Clotting Disorders.pdf important
PDF
MICROENCAPSULATION_NDDS_BPHARMACY__SEM VII_PCI Syllabus.pdf
PDF
Literature_Review_methods_ BRACU_MKT426 course material
PPTX
UNIT_2-__LIPIDS[1].pptx.................
PDF
Myanmar Dental Journal, The Journal of the Myanmar Dental Association (2013).pdf
PDF
PUBH1000 - Module 6: Global Health Tute Slides
PDF
Farming Based Livelihood Systems English Notes
PDF
Skin Care and Cosmetic Ingredients Dictionary ( PDFDrive ).pdf
PDF
LIFE & LIVING TRILOGY- PART (1) WHO ARE WE.pdf
PPTX
ACFE CERTIFICATION TRAINING ON LAW.pptx
Journal of Dental Science - UDMY (2021).pdf
Nurlina - Urban Planner Portfolio (english ver)
CAPACITY BUILDING PROGRAMME IN ADOLESCENT EDUCATION
BSCE 2 NIGHT (CHAPTER 2) just cases.pptx
Environmental Education MCQ BD2EE - Share Source.pdf
Everyday Spelling and Grammar by Kathi Wyldeck
faiz-khans about Radiotherapy Physics-02.pdf
fundamentals-of-heat-and-mass-transfer-6th-edition_incropera.pdf
Macbeth play - analysis .pptx english lit
LIFE & LIVING TRILOGY - PART - (2) THE PURPOSE OF LIFE.pdf
1.Salivary gland disease.pdf 3.Bleeding and Clotting Disorders.pdf important
MICROENCAPSULATION_NDDS_BPHARMACY__SEM VII_PCI Syllabus.pdf
Literature_Review_methods_ BRACU_MKT426 course material
UNIT_2-__LIPIDS[1].pptx.................
Myanmar Dental Journal, The Journal of the Myanmar Dental Association (2013).pdf
PUBH1000 - Module 6: Global Health Tute Slides
Farming Based Livelihood Systems English Notes
Skin Care and Cosmetic Ingredients Dictionary ( PDFDrive ).pdf
LIFE & LIVING TRILOGY- PART (1) WHO ARE WE.pdf
ACFE CERTIFICATION TRAINING ON LAW.pptx

Django tutorial

  • 2. Django i AbouttheTutorial Django is a web development framework that assists in building and maintaining quality web applications. Django helps eliminate repetitive tasks making the development process an easy and time saving experience. This tutorial gives a complete understanding of Django. Audience This tutorial is designed for developers who want to learn how to develop quality web applications using the smart techniques and tools offered by Django. Prerequisites Before you proceed, make sure that you understand the basics of procedural and object- oriented programming: control structures, data structures and variables, classes, objects, etc. Disclaimer&Copyright  Copyright 2015 by Tutorials Point (I) Pvt. Ltd. All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish any contents or a part of contents of this e-book in any manner without written consent of the publisher. We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial. If you discover any errors on our website or in this tutorial, please notify us at [email protected].
  • 3. Django ii TableofContents About the Tutorial....................................................................................................................................i Audience..................................................................................................................................................i Prerequisites............................................................................................................................................i Disclaimer & Copyright.............................................................................................................................i Table of Contents....................................................................................................................................ii 1. DJANGO – BASICS................................................................................................................1 History of Django ....................................................................................................................................1 Django – Design Philosophies..................................................................................................................1 Advantages of Django .............................................................................................................................1 2. DJANGO – OVERVIEW..........................................................................................................3 3. DJANGO – ENVIRONMENT...................................................................................................4 Step 1 – Installing Python........................................................................................................................4 Step 2 - Installing Django.........................................................................................................................4 Step 3 – Database Setup..........................................................................................................................6 Step 4 – Web Server................................................................................................................................6 4. DJANGO – CREATING A PROJECT.........................................................................................7 Create a Project.......................................................................................................................................7 The Project Structure ..............................................................................................................................7 Setting Up Your Project...........................................................................................................................8 5. DJANGO – APPS LIFE CYCLE ...............................................................................................10 6. DJANGO – ADMIN INTERFACE ...........................................................................................12 7. DJANGO – CREATING VIEWS..............................................................................................15
  • 4. Django iii 8. DJANGO – URL MAPPING ..................................................................................................17 9. DJANGO – TEMPLATE SYSTEM...........................................................................................23 The Render Function .............................................................................................................................23 Django Template Language (DTL)..........................................................................................................23 Filters....................................................................................................................................................24 Tags.......................................................................................................................................................24 10. DJANGO – MODELS ...........................................................................................................28 Creating a Model...................................................................................................................................28 Linking Models......................................................................................................................................30 11. DJANGO – PAGE REDIRECTION..........................................................................................33 12. SENDING E-MAILS..............................................................................................................36 Sending a Simple E-mail ........................................................................................................................36 Sending Multiple Mails with send_mass_mail.......................................................................................37 Sending HTML E-mail ............................................................................................................................39 Sending E-mail with Attachment...........................................................................................................41 13. DJANGO – GENERIC VIEWS................................................................................................42 14. DJANGO – FORM PROCESSING..........................................................................................46 15. DJANGO – FILE UPLOADING ..............................................................................................51 16. DJANGO – APACHE SETUP.................................................................................................55 17. DJANGO – COOKIES HANDLING.........................................................................................57 18. DJANGO – SESSIONS..........................................................................................................60
  • 5. Django iv 19. DJANGO – CACHING..........................................................................................................64 Setting Up Cache in Database................................................................................................................64 Setting Up Cache in File System.............................................................................................................65 Setting Up Cache in Memory.................................................................................................................65 Caching the Entire Site ..........................................................................................................................65 Caching a View......................................................................................................................................66 Caching a Template Fragment...............................................................................................................67 20. COMMENTS.......................................................................................................................69 21. DJANGO – RSS ...................................................................................................................74 22. DJANGO – AJAX .................................................................................................................78
  • 6. Django 5 Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Django makes it easier to build better web apps quickly and with less code. Note: Django is a registered trademark of the Django Software Foundation, and is licensed under BSD License. HistoryofDjango  2003: Started by Adrian Holovaty and Simon Willison as an internal project at the Lawrence Journal-World newspaper.  2005: Released July 2005 and named it Django, after the jazz guitarist Django Reinhardt.  2005: Mature enough to handle several high-traffic sites.  Current: Django is now an open source project with contributors across the world. Django–DesignPhilosophies Django comes with the following design philosophies:  Loosely Coupled: Django aims to make each element of its stack independent of the others.  Less Coding: Less code so in turn a quick development.  Don't Repeat Yourself (DRY): Everything should be developed only in exactly one place instead of repeating it again and again.  Fast Development: Django's philosophy is to do all it can to facilitate hyper-fast development.  Clean Design: Django strictly maintains a clean design throughout its own code and makes it easy to follow best web-development practices. AdvantagesofDjango Here are few advantages of using Django which can be listed out here: 1. DJANGO – BASICS
  • 7. Django 6  Object-Relational Mapping (ORM) Support: Django provides a bridge between the data model and the database engine, and supports a large set of database systems including MySQL, Oracle, Postgres, etc. Django also supports NoSQL database through Django-nonrel fork. For now, the only NoSQL databases supported are MongoDB and google app engine.  Multilingual Support: Django supports multilingual websites through its built-in internationalization system. So you can develop your website, which would support multiple languages.  Framework Support: Django has built-in support for Ajax, RSS, Caching and various other frameworks.  Administration GUI: Django provides a nice ready-to-use user interface for administrative activities.  Development Environment: Django comes with a lightweight web server to facilitate end-to-end application development and testing.
  • 8. Django 7 As you already know, Django is a Python web framework. And like most modern framework, Django supports the MVC pattern. First let's see what is the Model-View-Controller (MVC) pattern, and then we will look at Django’s specificity for the Model-View-Template (MVT) pattern. MVC Pattern When talking about applications that provides UI (web or desktop), we usually talk about MVC architecture. And as the name suggests, MVC pattern is based on three components: Model, View, and Controller. Check our MVC tutorial here to know more. DJANGO MVC - MVT Pattern The Model-View-Template (MVT) is slightly different from MVC. In fact the main difference between the two patterns is that Django itself takes care of the Controller part (Software Code that controls the interactions between the Model and View), leaving us with the template. The template is a HTML file mixed with Django Template Language (DTL). The following diagram illustrates how each of the components of the MVT pattern interacts with each other to serve a user request: The developer provides the Model, the view and the template then just maps it to a URL and Django does the magic to serve it to the user. 2. DJANGO – OVERVIEW
  • 9. Django 8 Django development environment consists of installing and setting up Python, Django, and a Database System. Since Django deals with web application, it's worth mentioning that you would need a web server setup as well. Step1–InstallingPython Django is written in 100% pure Python code, so you'll need to install Python on your system. Latest Django version requires Python 2.6.5 or higher for the 2.6.x branch or higher than 2.7.3 for the 2.7.x branch. If you're on one of the latest Linux or Mac OS X distribution, you probably already have Python installed. You can verify it by typing python command at a command prompt. If you see something like this, then Python is installed. $ python Python 2.7.5 (default, Jun 17 2014, 18:11:42) [GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2 Otherwise, you can download and install the latest version of Python from the link http://www.python.org/download. Step2-InstallingDjango Installing Django is very easy, but the steps required for its installation depends on your operating system. Since Python is a platform-independent language, Django has one package that works everywhere regardless of your operating system. You can download the latest version of Django from the link http://www.djangoproject.com/download. UNIX/Linux and Mac OS X Installation You have two ways of installing Django if you are running Linux or Mac OS system:  You can use the package manager of your OS, or use easy_install or pip if installed.  Install it manually using the official archive you downloaded before. We will cover the second option as the first one depends on your OS distribution. If you have decided to follow the first option, just be careful about the version of Django you are installing. 3. DJANGO – ENVIRONMENT
  • 10. Django 9 Let's say you got your archive from the link above, it should be something like Django- x.xx.tar.gz: Extract and install. $ tar xzvf Django-x.xx.tar.gz $ cd Django-x.xx $ sudo python setup.py install You can test your installation by running this command: $ django-admin.py --version If you see the current version of Django printed on the screen, then everything is set. Note: For some version of Django it will be django-admin the ".py" is removed. Windows Installation We assume you have your Django archive and python installed on your computer. First, PATH verification. On some version of windows (windows 7) you might need to make sure the Path system variable has the path the following C:Python27;C:Python27Libsite- packagesdjangobin in it, of course depending on your Python version. Then, extract and install Django. c:>cd c:Django-x.xx Next, install Django by running the following command for which you will need administrative privileges in windows shell "cmd": c:Django-x.xx>python setup.py install To test your installation, open a command prompt and type the following command: c:>django-admin.py --version If you see the current version of Django printed on screen, then everything is set. OR Launch a "cmd" prompt and type python then:
  • 11. Django 10 c:> python >>> import django >>> print django.get_version()
  • 12. Django 11 End of ebook preview If you liked what you saw… Buy it from our store @ https://store.tutorialspoint