Categories
Django Final Year Project Python

Django (not the movie)

For added ambience, listen to this song while reading.

django_logoDjango is a web framework. I only vaguely knew what that meant when I declared I was using it for my project. In a nutshell, it’s a way of plugging everything about a web application together in a coherent, structured way. That includes HTML, CSS, images, data stores and middleware. Anyone can write a CGI script in their favorite language that does nothing but spit out HTML to a browser, but that’s unnecessary with Django. In fact, Django won’t even let you embed any functional code within your HTML template. But we’ll get on to that later.

Django is an MVC web framework built on the Python programming language. MVC stands for Model – View – Controller, and is a massively important factor in the design of any Django web app. The Model represents the structure of the data used in the application. In most cases, your data will be stored in a typical relational database. The View typically defines what the user sees from an application and is often referred to as the front end or user interface. The Controller makes up the business logic of the application. It glues together the Model and View in a way that the View can both display data as stored in the Model and update the Model based on a user’s input.

Installing and getting started with Django is very straightforward. As I’m using a Debian-based Linux distribution for both development and deployment, installation is just one command:
apt-get install python-django

Creating a Django project is just another command:
django-admin startproject myproject

This creates the core files you need to get started with Django development. Each app has a manage.py file, as well as a directory named after your project. This project folder can be used to store HTML templates, as well as static content such as CSS files and images.

Anything that represents a key piece of functionality in a Django project is called an app. Apps are created with the manage.py script:
python manage.py startapp myapp

Each app is encapsulated in its own directory, inside of which are two important files: models.py and views.py. In these files, we define – yep, you guessed it – the models and views for the app.

In the second part of this post, I’ll explain what these files are in more detail, including what goes in to them to create a basic app.

Categories
Final Year Project

Final Year Project: Introduction

I have to admit that I wrote the Raspberry Pi off at first. I mean, my initial description of it as a “slow Linux computer” are technically correct, but I never really thought of looking at it for what it really is – a cheap, small and, least importantly, slow Linux computer.

Top-down view of Raspberry Pi
Top-down view of Raspberry Pi

I’ve been actively using Linux since 2009, with Ubuntu eventually becoming my primary OS in early 2010.  I think it was the early descriptions of the Pi as a teaching tool for programming that put me off. I couldn’t comprehend why a low-spec, awkwardly-shaped computer would be desirable as a platform to teach the art of coding, particularly when most schools have perfectly capable machines already in their possession.

But then I got my hands on one. And, almost immediately, I realized that the Pi really is something special.

My Final Year Project is entitled Smartphone-controlled media streaming application for Raspberry Pi. The idea behind this project is to create an open source web-based software stack for the Pi which allows it to be used as both a media streaming server (to be accessed remotely via a browser) and as a TV-connected home media center, utilizing the Pi’s HDMI output capabilities. I aim to achieve this using web applications instead of native GTK+ or Qt interfaces. The benefit of this, besides portability, is a unified interface for both the remote streaming feature and the intention for the device to be used as a HTPC (Home Theater PC).

The niche of this project, and arguably the most challenging aspect of it, is the requirement for the application to be controlled by a smartphone. This can’t just involve writing an app that can access the same data store as the web application, but must be able to control the web interface as if it were a standard remote control for a set-top box or smart TV interface.

High-level architecture of project
High-level architecture of project

I like Python. But, due to a combination of time constraints and how easily I’m distracted by shiny objects, I’ve written very little of it. Coupled with this, I’ve been intrigued by the Django framework for a while now. Partly due to its maturity and its wide community of developers, I’ve decided that it would be a good fit for the user-facing requirements of this project. The other part of my reasoning isn’t so much reasoning as it is curiosity. Other technologies I intend on using are: Nginx for the web server, PostgreSQL for the back-end data store, HTML, CSS and JavaScript for the web design and Java/SL4A for the mobile application, many of which I also have little experience with.

The way I figure it, what’s the point of engaging in a project if you’re not going to step outside your comfort zone so many times that the end goal appears to be a blurry vision of accomplishment, led to by a path made mostly of fire? And stack traces. Millions of them. And they’re also on fire.