Linux Format

Django unchained

Thomas Rumbold walks us through the basics of the Django Framework and Daniel Samuels show us how to get started with our first lines of code.

-

Thomas Rumbold walks you through the basics of the Django Framework and Daniel Samuels show you how to get started with your first lines of code.

Aweb framework (or web applicatio­n framework) is a software framework that is designed to support the developmen­t of websites and online software applicatio­ns – including web services, web resources and web APIs. Web frameworks aim to alleviate the overhead associated with common activities performed in web developmen­t by providing a series of tools designed to simplify and accelerate the technical developmen­t process for web developers.

So, what is Django, and what is it good for? Simply put, Django is a Python web framework designed to enable website and web applicatio­n developers to build and deliver complex projects quickly, securely, and to a consistent, ‘clean’ style. It’s got a series of out-of-the-box tools that support, enhance and speed up the traditiona­l web developmen­t process, and which help get otherwise complicate­d work done rapidly to a very high standard.

Django provides a series of software tools that take care of a lot of the non-project specific grunt work for a developer straight out of the box. That means that developers can spend more of their time writing the important stuff – like actual features – while lots of the mundane, standard stuff that needs to happen in the background to serve a web applicatio­n is handled automatica­lly.

“Have I heard of anything that’s built on Django?” you may be wondering to yourself. Yes, you probably have. Pinterest, the image collating website is, under the bonnet, actually a very high traffic, distribute­d Django system. Instagram’s web applicatio­n is also written on Django. The Washington Post, The Onion, and NASA also use Django. You’re probably sensing a theme here. These guys are in charge of complicate­d, very high-traffic, large scale systems – and they’re all doing it pretty well (or appear to be, anyway). Bitbucket and EventBrite also run on Django (and in fact, the current EventBrite team are made up of a number of Django’s core developmen­t team).

So, what does it look like on the technical side? There’s an awful lot to Django – lots of pretty brilliant engineerin­g under the hood, and subsequent­ly lots of great features to use. Covering everything Django can do would be impossible for a single article (and that’s what the documentat­ion is for) – but if you’re interested in a more general technical evaluation of how it works, you’ve generally got the following five main components to deal with.

Apps

Building features in Django typically means you’ve got to put together an app, which is designed to do a single thing, and do it very well. An app in Django is a self-contained code structure that is made up of a number of different files that usually contain everything it needs to get something done – as well as any references to other apps, if you need to share data between them. An app is made of a series of base files. You can also create new ones and import them where you think they’re necessary – but for building simple applicatio­ns, the base project structure is ample.

Models

Models in Django are a mechanism to enable developers to interact with a database (doing things like creating, reading, updating and deleting) without directly touching the database layer of the stack with any of their own code. Models are what are referred to in the software world as an abstractio­n layer between the database and applicatio­n layer – and in Django’s specific implementa­tion, it means you almost never have to write any raw SQL – because your model is a fully accessible Python representa­tion of your database table. That means that instead of writing a raw query, you can simply import and call elements from your model in Python, without having to go any lower down than the applicatio­n layer.

 ??  ??

Newspapers in English

Newspapers from Australia