Django
Programming
For Beginners
Learn Coding Fast!
Ray Yao
Copyright 2015 by Ray Yao
All Rights Reserved
Neither part of this book nor whole of this book may be reproduced or transmitted in any form or by any means electronic, photographic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without prior written permission from the author . All rights reserved !
Ray Yao
Ray Yaos eBooks & Books on Amazon
Advanced C++ Programming by Ray Yao
Advanced Java Programming by Ray Yao
AngularJs Programming by Ray Yao
C# Programming by Ray Yao
C# Interview & Certification Exam
C++ Programming by Ray Yao
C++ Interview & Certification Exam
Django Programming by Ray Yao
Go Programming by Ray Yao
Html Css Programming by Ray Yao
Html Css Interview & Certification Exam
Java Programming by Ray Yao
Java Interview & Certification Exam
JavaScript Programming by Ray Yao
JavaScript 50 Useful Programs
JavaScript Interview & Certification Exam
JQuery Programming by Ray Yao
JQuery Interview & Certification Exam
Kotlin Programming by Ray Yao
Linux Command Line
Linux Interview & Certification Exam
MySql Programming by Ray Yao
Node.Js Programming by Ray Yao
Php Interview & Certification Exam
Php MySql Programming by Ray Yao
PowerShell Programming by Ray Yao
Python Programming by Ray Yao
Python Interview & Certification Exam
R Programming by Ray Yao
Ruby Programming by Ray Yao
Rust Programming by Ray Yao
Scala Programming by Ray Yao
Shell Scripting Programming by Ray Yao
Visual Basic Programming by Ray Yao
Visual Basic Interview & Certification Exam
Xml Json Programming by Ray Yao
Preface
Django Programming covers all essential Django knowledge . You can learn complete primary skills of Django fast and easily .
The book includes more than 60 practical examples for beginners and includes tests & answers for the college exam, the engineer certification exam, and the job interview exam .
Note:
Before you learn Django programming, you must have the knowledge of the Python language .
Source Code for Download
This book provides source code for download; you can download the source code for better study, or copy the source code to your favorite editor to test the programs .
Source code download link:
https://forms . aweber . com/form/31/448508031 . htm
Table of Content
Chapter 1
Django Introduction
What is Django?
Django is an open source web application framework written in Python using the framework pattern of MVC, namely model M, view V, and controller C . It was originally developed to manage some news-focused websites of Lawrence publishing's, namely it is a CMS, released under the BSD license in July 2005 . The framework is named after Django Reinhardt, a Belgian gypsy jazz guitarist .
Who is suitable for reading this book?
The people who know the Python programming .
The people who want to create web applications and build websites .
The beginners who want to become a Django programmer .
Install Django
Because Django was written in Python, you should install Python first before install Django .
Download Python
Free download Python-3 . . 1 installer at:
https://www . python . org/downloads/
Install Python
When the download finishes, run the installer by double-clicking it . Install Python to your local computer, check Add Python 3.7 to PATH .
Then click Customize installation into next step .
Click next .
Customize install location as C:\Python37 , then click Install .
Finally, you can see that the Python installation was successful .
Run Python
Please click Start > Programs > Python3 . 7 > IDLE (Python GUI) .
Or
Click Start > Programs > Python3 . 7 > Python (Command Line) .
You will see Python prompt:
>>>
Test Python Program
print ( ) is used to print text or string to the screen .
For example
>>> print ("Hello World ! ")
Output: Hello World !
For example
>>> print ("Python is a very good language ! ")
Output: Python is a very good language !
Download Django
https://www . djangoproject . com/download/
On the right side of the download web page, please click the Latest Release: Django-2.1.3.tar.gz , download the Django to your local computer, and unzip the software Django-2 . . . tar . gz in current folder .
After you unzip the software, you can see a folder name Django-2 . . . Please copy Django-2 . . 3 folder and its contents to C:\.
Now make sure that there are Python37 folder and Django-2 . . 3 folder under C:\ root directory .
And make sure that there is a file setup . py under Django-2 . . 3 folder .
Under the C:\Django-2 . . 3, you can see the file setup . py .
Install Django
Open a command prompt with cmd command, input following commands:
Explanation:
cd\ returns to C: \ root directory .
cd django-2.1.3 goes to the folder django-2 . . .
python setup.py install installs the Django to your computer .
When installation is finished, you can see something like this:
Congratulation ! Django is installed successfully !
Test Django
Open a command prompt with cmd command, input following commands:
C:\Django-2 . . 3>python
>>> import django
>>> print django . get_version( )
Output:
. .
Explanation:
The output shows the 2 . . 3, which is the installed Django version . That means the Django installation is successful !