Django is based on the Model-View-Controller (MVC) design pattern. This means that database, program code (back-end) and display code (front-end) are separate.
Django takes this separation one step further by separating code from the static media—images, files, CSS and JavaScript—that make up your site.
These design philosophies allow you to:
- Run separate servers for your database, applications and media;
- Easily have your media served from a Content Delivery Network (CDN);
- Cache content at multiple levels and scopes; and
- For really big sites, employ clustering and load-balancing to distribute your website across multiple servers.
Django supports a range of popular third-party vendors for web servers, performance management, caching, clustering and balancing.
It also supports major email and messaging applications and services like OAuth and ReST.
It can be hard to get started with Django because it’s such a huge project, but if you take the time to understand how all parts come together at a high level, you’ll master Django much quicker.
At the highest level, Django is a Model-View-Controller – or MVC – framework.
MVC is a software design pattern that aims to separate a web application into three interconnecting parts:
- The model, which provides the interface with the database containing the application data;
- The view, which decides what information to present to the user and collects information from the user; and
- The controller, which manages the business logic for the application and acts as an information broker between the model and the view.
Django uses slightly different terminology in its implementation of MVC (Figure shown below). In Django:
- The model is functionally the same. Django’s Object-Relational Mapping (ORM—more on the ORM later) provides the interface to the application database;
- The template provides display logic and is the interface between the user and your Django application; and
- The view manages the bulk of the applications data processing, application logic and messaging.
A pictorial description of the Model-Template-View (MTV) pattern in Django.
The MVC design pattern has been used for both desktop and web applications for many years, so there are a large number of variations on this theme—of which Django is no exception.
Django is a Python-based web framework which allows you to quickly create web application without all of the installation or dependency problems that you normally will find with other frameworks.
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. Django gives you ready-made components to use.
In the next post we shall discuss Django Models.
0 comments:
Post a Comment