Tuesday, June 26, 2012

My Journey in Python & Django: Hello World

I have been developing with Python/Django for a little while now. In most cases I have helped build something that has already been started. Recently I took part in another Health 2.0 Developer Challenge to build LessBadd.com (aka BMoreGood.com). There were some lessons from that intense weekend process. Things like this:

- Getting Python running in a shared server environment
- Particularly when you want to run Mongo alongside your application
- Integrating an easy to use stylesheet platform for CSS
- Integrating SMS and a Web front end with a common RESTful API backend.

This led me to take a step back and consider what I need for a basic "Hello World" Django app. What I want to build is a basic framework that is ready for adaptation for future projects.

For self contained Python/Django projects the configuration should be able to run in an Apache shared hosting environment but for any solution that requires additional capabilities such as Mongo then running in an Amazon EC2 instance is the way to go.

So what base configuration do I want?

Here is my thinking:

Python/Django with sqlite3 database
SASS pre-processor for CSS
Compass to handle automatic compilation of CSS stylesheet changes. This only needs to be installed locally and the changes uploaded to GitHub or the target server.
Bootstrap a CSS toolkit developed by Twitter for basic web site design

Inside the basic Hello World App I want to set up:

- An Apps folder to store different modules
- A db folder for the database files
- A Mainstatic folder to store static images and stylesheets etc.
- A Templates folder to store the HTML templates for the application.
- A Config folder where the application requirements file will be stored together with standard setup instructions.

This is the starting point. I plan to upload the basic Hello World configuration to Github so it can be used as a starting point for other applications. 

I plan on documenting the process in a series of blog posts. I have found Python and Django to be a powerful combination for rapid application development. However, integrating code from around the web can be frustrating. Making sure you have all the dependent modules in place can be a challenge. I therefore intend to document the creation of this Hello World application as completely as I can. I am sure there will be some challenges along the way, but by sharing the lessons learned I hope it can make it easier for others that are stepping along this learning curve.

There are some functional elements I want to address such as:

- Using Virtual Environments in Python via VirtualEnv to isolate each Python environment 
- Incorporating Social Network authentication and login to a User Profile configuration.
- Using the Bootstrap CSS toolkit that is responsive to various screen sizes and therefore runs well on Smartphones and Tablets

The first step is to isolate each Python Environment. To do this we will use VirtualEnv. This allows us to insulate each application from other development apps. This allows different versions of python and different additional modules to be configured - without the risk of "cross contamination" and unexpected interactions between applications.

Another early challenge is implementing Bootstrap from Twitter. The CSS Framework is getting quite a it of attention but it seems to have been originally developed to work with Ruby on Rails and the LESS pre-processor. 

So watch out for future posts that attempt to document this effort. I hope you find it useful.

Posted via email from ekivemark: pre-blogspot