With Django, you can take Web applications from concept to launch in a matter of hours. Django takes care of much of the hassle of Web development, so you can focus on writing your app without needing to reinvent the wheel. It’s free and open source. (docs)
Django follows the MVC pattern closely, however it does use its own logic in the implementation. Because the “C” is handled by the framework itself and most of the excitement in Django happens in models, templates, and views, Django is often referred to as an MTV framework. In the MTV development pattern:
M stands for “Model” the data access layer. This layer contains anything and everything about the data: how to access it, how to validate it, which behaviors it has, and the relationships between the data.
T stands for “Template” the presentation layer. This layer contains presentation-related decisions: how something should be displayed on a Web page or other type of document.
V stands for “View” the business logic layer. This layer contains the logic that accesses the model and defers to the appropriate template(s). You can think of it as the bridge between models and templates.
Django is not just limited to MTV, we can use any other front-end framework(React, Angular) instead of using base design pattern.
Many of us use Django to build Rest APIs. as Django written in python so it has a lot of flexibilities.
The best thing I like about Django is its Admin panel to maintain models.
Django admin can easily be customized, like uploading a file via admin(action in the list view of a model) and many more.
Writting first Django Views (Hello World!)
This will create some folder structure like below
django-admin startproject helloworld.
helloworld/ manage.py helloworld/ __init__.py settings.py urls.py wsgi.pyCreate a new app which contains your views.
python manage.py startapp polls
This will create some more file for your app. structure is below
polls/ __init__.py admin.py apps.py migrations/ __init__.py models.py tests.py views.pyNow let us start writting our view. Like in the polls app open up view.py and write bellow codes
from django.http import HttpResponse def hello(request): return HttpResponse("Hello world")Lets see what we wrote up:
urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^hello/$', hello), ]
Run the server
Congrats ! Our hello world server is ready.
python manage.py runserver
- Django was designed with the intention to make a framework which takes less time to build the web application. The project implementation phase is a very time taken but Django creates it rapidly.
- Django takes security seriously and helps developers to avoid many common security mistakes, such as SQL injection, cross-site scripting, cross-site request forgery etc. Its user authentication system provides a secure way to manage user accounts and passwords.
- Django is scalable in nature and has an ability to quickly and flexibly switch from small to large scale application project.
- Django includes various helping task modules and libraries which can be used to handle common Web development tasks. Django takes care of user authentication, content administration, sitemaps, RSS feeds etc.
- Django is versatile in nature which allows it to build applications for different-different domains. Nowadays, Companies are using Django to build various types of applications like content management systems, social networks sites or scientific computing platforms etc.
- Django is an open source web application framework. It is publicly available without cost. It can be downloaded with source code from the public repository. Open source reduces the total cost of the application development.
Vast and supported Community
- Django is one of the most popular web frameworks. It has widely supportive community and channels to share and connect.