Sunday, September 15, 2019

Django : a web application software framework

IntroductionDjango is pronounced as JANG-oh (जेंगो).  
  • it is a registered trademark of the Django Software Foundation and is licensed under BSD (Berkeley Source Distribution) Licence. 
  • it was named after the famous guitarist Django Reinhardt. 
  • It was developed by Adrian Holovaty and Simon Willison at the Lawrence Journal-World newspaper for efficient development in Python. 
  • It was open sourced in 2005 and its first version was released on September 3, 2008.

Django is a free, open source web framework written in the Python programming language. it is very popular nowadays due to its friendly environment. it is robust and flexible so used by Instagram, Pinterest, bitbucket, Disqus etc. Django runs on all operating system such as UNIX, Windows, Mac and Solaris. It officially supports four databases- PostgreSQL, MySQL, SQlite and Oracle.
A web framework is a set of components that helps us develop websites faster and easier. A web framework provides the 04 basic things-
1-URL (Uniform Resource Locator) mapping
2- Database manipulation
3- Template
4- Security measures

Examples of Web framework:

CLIENT SIDE: -  

FLASK (PYTHON) 
EXPRESS (Java/Script) 
RUBY on Rails (RUBY) 
Mojolicius (Perl)

SERVER SIDE:-

ASP.NET Core
Zend Framework
Django


Advantage of Django:

  • Object Relational Mapping (ORM) Support :
    • Django provides a bridge between the data model and the database engine and supports a large set of database system including MySQL, Oracle, Postgres etc.
  • Supports No-SQL Database.
  • Support to various languages.
  • Support of Framework.
  • Administration GUI
  • Development Environment
  • Loosely Coupled
    • Django aims to make each element of its stack independent of others.
  • Less Coding
  • Don’t Repeat Yourself (DRY)
  • Scalable
  • Secured

How Django works?   Django see here in video

  • It supports MVT or MTV architecture (Model Template View)
  • Request/Response System: Django has the software components which facilitates receiving and responding of web requests.
  • Web Request enters in django applications via URLs.
  • Request are processed by views.
  • And then web response returns.

Django  Working Model




Django Request - Response cycle



DJANGO INSTALLATION

The installation of Django requires prior to :
  • Install Python (only for the first time)
  • Install the Python Package Repository (PyPi),the ip tool ( Only for the first time)
  • Install the Python Virtual Environment (Only for the first time)
if not installed yet python then follow the given steps:-
  •  Install Python form  https://www.python.org/downloads/ and click the big yellow button that says "Download Python 3.6.5". Now go to your downloads folder and double click the file "Python-3.x.x.msi" to run the installer. Make sure you have checked the Add Python 3.6 to path.
  • Go to the command prompt (type cmd in search menu) and get back to root.
    • c:\users> cd\
    • c:\> python -m pip install -U pip
  • Install the Python Virtual Environment (Only for the first time).
    • c:\> pip install virtualenv
  • Create and enter a root directory for all your projects (only for the first time).
    • c:\> md myprojects
    • c:\> cd myprojects
  • Create a Virtual Environment (Only for the first time)
    • c:\>myprojects> virtualenv django
  • Install Django (Only for the first time)
    • c:\myprojects>pip install Django
    • here Django gets successfully installed onto your system and is ready to use.
  • CREATING Django Projects: (you can name it as per your choice here it is given name as "demo")
    • c:\> cd myprojects>django-admin startproject demo
  • Run the server locally :-
    • c:\>myprojects\demo> python manage.py runserver
    • note: everytime you run Django, you have to run the server by typing the command: > python manage.py runserver
    • now server will start working and minimize the command prompt window.
  • Now type  http://127.0.0.1:8000/ with your web browser ( Google Crome, Internet Explorer) You will see "The install worked successfully ! Congratulations!"


Note : Every time you have to start a new project in windows, all the above steps after Django installation have to be executed again and the window is minimized, and Django server is to be kept running for all the successive projects you will develop in Django.



snapshots of above steps 

  • open command prompt (cmd ) and type command underlined with yellow colour.



  • Now browse through Windows Explorer and open project titled "demo".
  • Edit urls.py (edit with IDLE) which gets automatically created inside demo folder.

  • Create views.py in the same folder ( c:\myprjoects\demo\demo) by clicking on it and selecting new-> Text Document . save it with the file name as views.py and edit it with the following code:-

  • Now type http://127.0.0.1:8000/ at the address bar of your web browser and press enter. The following output window shall be displayed:-










No comments:

Post a Comment

Note: Only a member of this blog may post a comment.