what is django and where to begin !
django is a big and scaleable web-framework for python programming language. It’s widely used all around the web and it’s really easy to work with and learn. In this article you’ll learn everything you need to know before starting to learn it.
What is Django?
Django is a high-level Python web framework that enables rapid development of secure and maintainable websites. Built by experienced developers, 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 is free and open source. Has a thriving and active community, great documentation, and many options for free and paid-for support.
Django helps you write software that is:
- Django follows the “Batteries included” philosophy and provides almost everything developers might want to do “out of the box”. Because everything you need is part of the one “product”, it all works seamlessly together, follows consistent design principles, and has extensive and up-to-date documentation.
- you can use django to build almost any type of website. From content management systems and wikis, through to social networks and news sites. It can work with any client-side framework, and can deliver content in almost any format (including HTML, RSS feeds, JSON, XML, etc). The site you are currently reading is build with Django!
Internally, while it provides choices for almost any functionality you might want (e.g. several popular databases, templating engines, etc.). It can also extends to use other components if needed.
- Django helps developers avoid many common security mistakes. A framework that that purpose of it’s creation is to “do the right things”. To protect the website automatically. For example, Django provides a secure way to manage user accounts and passwords. So avoiding common mistakes like putting session information in cookies where it is vulnerable. Instead of cookies just contain a key, and the actual data is stored in the database). Directly storing passwords rather than a password hash.
A password hash is a fixed-length value created by sending the password through a cryptographic hash function. Django can check if an entered password is correct by running it through the hash function and comparing the output to the stored hash value. However due to the “one-way” nature of the function, even if a stored hash value is compromised it is hard for an attacker to work out the original password.
So django enables protection against many vulnerabilities by default, including SQL injection, cross-site scripting, cross-site request forgery and clickjacking (see Website security for more details of such attacks).
- Django uses a component-based “shared-nothing” architecture (each part of the architecture is independent of the others, and can hence be replaced or changed if needed). Having a clear separation between the different parts. Means that it can scale for increased traffic by adding hardware at any level. Caching servers, database servers, or application servers. Some of the busiest sites have successfully scaled Django to meet their demands (e.g. Instagram and Disqus, to name just two).
- Django code is write using design principles and patterns that encourage the creation of maintainable and reusable code. In particular, it makes use of the Don’t Repeat Yourself (DRY) principle. So there is no unnecessary duplication, reducing the amount of code. Django also promotes the grouping of related functionality into reusable “applications” and, at a lower level, groups related code into modules (along the lines of the Model View Controller (MVC) pattern).
- Django is in Python language, which runs on many platforms. So That means that you don’t have to any particular server platform. And can run your applications on many flavours of Linux, Windows, and Mac OS X. Furthermore, Django is well-support by many web hosting providers, who often provide specific infrastructure and documentation for hosting Django sites.
Where did it come from?
Django was initially developed between 2003 and 2005 by a web team who were responsible for creating and maintaining newspaper websites. After creating a number of sites, the team began to factor out and reuse lots of common code and design patterns. This common code evolve into a generic web development framework, which was open-sourced as the “Django” project in July 2005.
Django has continued to grow and improve, from its first milestone release (1.0) in September 2008 through to the recently-released version 3.1 (2020). Each release has added new functionality and bug fixes, ranging from support for new types of databases, template engines, and caching, through to the addition of “generic” view functions and classes (which reduce the amount of code that developers have to write for a number of programming tasks).
Django is now a thriving, collaborative open source project, with many thousands of users and contributors. While it does still have some features that reflect its origin, Django has evolved into a versatile framework that is capable of developing any type of website.
How popular is Django?
There isn’t any readily-available and definitive measurement of popularity of server-side frameworks. Although you can estimate popularity using mechanisms like counting the number of GitHub projects and StackOverflow questions for each platform. Hence a better question is whether Django is “popular enough” to avoid the problems of unpopular platforms. So is it continuing to evolve? Can you get help if you need it? Is there an opportunity for you to get payment work if you learn Django?
Based on the number of high profile sites that use Django, the number of people contributing to the codebase, and the number of people providing both free and paid for support, then yes, Django is a popular framework!
High-profile sites that use Django include: Disqus, Instagram, Knight Foundation, MacArthur Foundation, Mozilla, National Geographic, Open Knowledge Foundation, Pinterest, and Open Stack (source: Django overview page).
Is Django opinionated?
Web frameworks often refer to themselves as “opinionated” or “unopinionated”.
Opinionated frameworks are those with opinions about the “right way” to handle any particular task. They often support rapid development in a particular domain (solving problems of a particular type) because the right way to do anything is usually well-understood and well-documented. However they can be less flexible at solving problems outside their main domain, and tend to offer fewer choices for what components and approaches they can use.
Unopinionated frameworks, by contrast, have far fewer restrictions on the best way to glue components together to achieve a goal. Or even what components should be used. They make it easier for developers to use the most suitable tools to complete a particular task. Albeit at the cost that you need to find those components yourself.
Django is “somewhat opinionated”, and hence delivers the “best of both worlds”. It provides a set of components to handle most web development tasks and one (or two) preferred ways to use them. However, Django’s decoupled architecture means that you can usually pick and choose from a number of different options, or add support for completely new ones if desired.
Congratulations, you’ve completed the first step in your Django journey! You should now understand Django’s main benefits, a little about its history, and roughly what each of the main parts of a Django app might look like. You should have also learned a few things about the Python programming language, including the syntax for lists, functions, and classes.