Facts You Must Know About DJANGO Python
DJANGO: THE FRAMEWORK BY PYTHON
Two new terms in the title itself. Django is nothing but a framework by Python language. Doesn’t make sense? Easy. I am here to explain. According to the English definition of framework, it is any basic structure underlying a system, concept or text. It also means an essential supporting structure of a building, vehicle, or object.
In computer systems, a framework is often a layered structure indicating what kind of programs can or should be built and how they would interrelate. Before I proceed, I should give my readers an outline of what a framework is.
What is Django?
Django is a free and open source web application framework, written in Python. A web framework is a set of components that help you to develop websites faster and easier.
When you’re building a website, you always need a similar set of components: a way to handle user authentication (signing up, signing in, signing out), a management panel for your website, forms, a way to upload files, etc.
Frameworks exist to save you from having to reinvent the wheel and to help alleviate some of the overhead when you’re building a new site.
What happens when someone requests a website from your server in Django?
To understand what Django is actually for, we need to take a closer look at the servers. The first thing is that the server needs to know that you want it to serve you a web page.
When a request comes to a web server, it’s passed to Django which tries to figure out what is actually requested. It takes a web page address first and tries to figure out what to do. This part is done by Django’s URL Resolver. It is not very smart – it takes a list of patterns and tries to match the URL. Django checks patterns from top to bottom and if something is matched, then Django passes the request to the associated function which is called view. To explain at a more basic level, it’s like a mail carrier with a letter. He is walking down the street and checks each house number against the one on the letter. If it matches, he puts the letter there. This is how it works! In the view function, all the interesting things are done: we can look at a database to look for some information. Maybe the user asked to change something in the data? Like a letter saying, “Please change the description of my job.” The view can check if you are allowed to do that, then update the job description for you and send back a message: “Done!” Then the view generates a response and Django can send it to the user’s web browser.
Features of Django:
- It is lightweight and standalone web server for development and testing
- It uses form serialization and validation system that can translate between HTML forms and values suitable for storage in the database
- It has template system that utilizes the concept of inheritance borrowed from object-oriented programming(OOP)
- It has a caching framework that can use any of several cache methods
- It has support for middleware classes that can intervene at various stages of request processing and carry out custom functions
- It has an internal dispatcher system that allows components of an application to communicate events to each other via pre-defined signals
- It has an internationalization system, including translations of Django’s own components into a variety of languages
- It has a serialization system that can produce and read XML and/or JSON representations of Django model instances
- It is a system for extending the capabilities of the template engine
- Uses an interface to Python’s built-in unit test framework
- The main Django distribution also bundles a number of applications in its “contrib” package, including:
- An extensible authentication system
- The dynamic administrative interface
- Tools for generating RSS and Atom syndication feeds
- A site’s framework that allows one Django installation to run multiple websites, each with their own content and applications
- Tools for generating Google Sitemaps
- Built-in mitigation for cross-site request forgery, cross-site scripting, SQL injection, password cracking and other typical web attacks, most of them turned on by default
- A framework for creating GIS applications
ADVANTAGES of Django OVER OTHER FRAMEWORKS:
Django itself has several advantages over other frameworks. The design of Django began with a single, unified team whose task was to manage a series of news websites. These sites were, obviously, dynamic in nature, but needed to be efficient, clean and reusable. Thus, with this focus in mind, the creators of Django designed the framework to be tightly integrated, efficient, reusable and speedy from the start. This differs from others such as PHP and its corresponding frameworks in one critical area – there are many, many versions of PHP and frameworks for each of them. Thus, each framework brings different things to the table, is not tightly integrated, and may not be as efficient as possible without a specific goal in mind.
Likewise, Django also features a great ORM (object-relation mapper), which allows for greater flexibility within the application. With Django, switching from one database to another is as simple as changing a configuration file, whereas switching databases with another framework, such as a PHP framework, would require a huge amount of work and refactoring.3
Finally, Django is fairly lightweight but incredibly powerful. The framework provides libraries and functions for many common functions, yet is still flexible enough to be modified by an individual developer. It is also able to handle raw CRUD commands, among other low-level implementations that other frameworks do not allow. This is in direct contrast to other frameworks, such as Ruby on Rails, where the developer is restricted in what he/she can accomplish. Many frameworks are restricting about playing within their sandbox, but Django is flexible enough to allow the user direct access to databases and other low-level details where needed.
Django vs Pyramid: Battle of frameworks
Flexibility: Django is flexible | Pyramid is much more flexible than Django |
Admin Interface: One of the killer features of Django is its admin interface. It makes it really easy to generate an administration site straight from an application’s models | Pyramid isn’t really a winner in admin interface against Django |
Ease of Ajax: Django doesn’t win on this one as much as Pyramid does. | Pyramid wins this one. Use of decorators and XHR views make it very easy to get AJAX requests to go where you want them |
Code Layout: Django makes use of things called applications in order to make it easy to plug new capabilities into your product. This is very good in a way because it encourages developers to write code that is self-contained | Pyramid isn’t quite good with its code layout as far as comparing it with Django is concerned |
Community and Support:
The communities that use and support Django are huge.
| Here it is a tie. The communities using Pyramid are as huge as that of Django. |
1 comments:
Thanks for sharing this post.also visit my articles
php interview questions
Post a Comment