Introduction

Note, this is mainly introductory, so you could just scan through, make sure you've got the stuff you need, and head on to the next section

Blogger, Wordpress, Typepad and the legion of a million blog platforms - they are all better than what I offer here.  Thousands of open source web content management systems.  Many are greater than what we will talk about here.  And if you want to flex your muscles and say that you did it the hard way, well write your engine in C (I'll even admire you for writing a blog engine in plain PHP). 

So, it is not the most convenient or easiest, nor is it the hardest. 

But, what Django offers you is Lego blocks, the chance to craft something of your own imagination, a blog engine made your way, made by you, and it gives you all the support you need (documentation and community). 

And, we all know, there is only one cool scripting language, right?  Python.  Python has soul.  And Django is deeply Pythonic. 

So, do you want to get creative, do you want to be cool - write a blog with Django (I know you want to). 


I am not sure that I wrote this for any real audience - does anyone but me want to write a blog engine, or is it, well, done… boring?  Perhaps.  I gained a lot just writing it, and so that is enough to justify my doing it.  But it certainly would thrill me to bits if someone finds some, if not all, of the tutorial of some use.  If you did, why not send me a Tweet @sandcurves


What is this about:  This is a very simple tutorial to take you through building a blog using Django.  It is simple, but it's not short.  Don't let the length fool you into thinking that it's difficult, it isn't. 

Django is mainly aimed at small groups of developers, but with this tutorial you should be able to do every aspect by yourself.  My main goal is a tutorial where almost anyone with some patience and the right set of tools (which are all open source, or free software if you care to distinguish, except for your computer itself and somewhere to host) can build their own blog engine. 

Who will benefit the most:  I am writing this post as a way to document doing exactly what I had to learn to do.  So, to benefit the most you need to have some of the things I do.  You'll certainly be able to make use of it even if you use some different tool, but I am going to write with the assumption that we are doing everything the same way. 

You will benefit most if:

  • You have some idea what Python is about. I am not a programmer, but have done several tutorials and worked very thoroughly through Dive Into Python by Mark Pilgrim.  If that is your sort of level of experience with the language, you'll do dandy.  You will, of course, need to be sure Python (version 2.6ish) is on your system.  If you have Linux, you should be all set already. 
    I am not going to teach you the Python needed to understand all this stuff.  You should at a minimum understand basic string manipulation, use of tuples, lists and dictionaries and the very basics of regular expression.  If I did try to teach you the Python, this would turn into a book instead of a simple tutorial. 
    But, if you have only a real minimal experience with Python, and learn it alongside this tutorial, you should do fine.  It will just take you more time. 
  • You need to have Sqlite3.  If you have a normal Python installation, you should be fine anyway.  We'll only use Sqlite3 for the development.  Once you upload, use MySQL.  Don't worry to much about that, I'll cover it all in detail. 
  • I work on Ubuntu 10.04.  If you are on a similar Linux system, you'll be able to follow along well.  If you don't have Ubuntu, but want to try it, you can have it alongside your regular operating system.  There is plenty of advice on how to do that on the web.  If you are not on a Linux system, this tutorial is going to be very difficult to follow. 
  • We are going to work a lot with the Terminal.  If you don't even know what this is, so long as you are on Ubuntu, I'll talk you right into it.  You can do a beginner tutorial in bash
  • Have some idea about how HTML and CSS work.  I'm going to give you the stuff you need to get the tutorial working, and you can simply copy and paste, but the whole point of rolling your own blog engine is so that you can have some autonomy as to both how it looks and how it works.  So, later on you'll want to learn a bit more and make your website yours!
  • This isn't required, but I think using a good text editor like Emacs helps a lot. 
  • I am going to assume that you want to load it up to a hosted server.  I will explain how to do it with Hostgator.  It is just because I host (indirectly) with them, and it was a really tough job to get everything working.  You may find some of what I say useful even if you host elsewhere. 
  • I'm not going to get to much into working with images, but if you are working on websites, you'll sooner or later want some image editing capability.  For some reason Ubuntu 10.04 has stopped including gimp.  I think some decision makers fell out of a tree and hit their heads hard on a rock.  Get the gimp if you don't already have it.  If you don't have it, simply type "sudo apt-get install gimp" in Terminal, and wait a while.  Don't know what's terminal, we'll get to that. 
  • You need a web browser.  Actually, eventually you want at least access to a few to check that things look rocking in most popular browsers.  For the tutorial, I'm going to assume you are using Firefox
  • A little time, patience to read the tutorial, and coffee [ Mmmm, lets break a minute to get ourselves a cup, shall we. ]  If you don't drink coffee… well, of course you drink coffee… you're a Linux geek. 

Some Advice for doing the tutorial

If you are experienced, this is probably not the tutorial for you anyway.  You may get something out of it, but you are probably going to find it really slow and boring.  If you are a total beginner with this stuff, I advise you to follow the tutorial to a tee, do exactly what I say.  Once you have done the whole thing, then start digging into more of the Django documentation, get help on forums and start to play around with it.  If you play around to early, you'll get lost, and probably not finish the tutorial.  On the flip side, if you do the whole tutorial and you never play around with it, you'll also have lost out.  But, if you want to learn how to do this, follow the entire tutorial, all the way through.  I usually do tutorials like this in w3m browser, in Emacs - if you can do it in a text browser (in which it works great) you should - simply to keep twitter and the like quiet. 

If you are somewhere in the middle - you have a good bit of Python, and you have already picked at the Django documentation and just get stuck here and there on exactly how to go about getting a blog working, this should be just the tutorial for you.  When it seems difficult, it is most likely that you are going to fast, or not concentrating on the details.  Look at it clearly, and occasionally go back a few times. 

When writing the tutorial, which I did in a few chunks, what I would do is create a blog on my computer following along, then I just delete the whole thing and do it again, over and over.  In so doing, I know that everything is working, though I didn't put it up on a server.  I am working on another non-blog website with Django, and so could test out some of what I said while I worked on that site.  If you are trying to get a good grip of doing Django websites, I advise you to do the same - build one, delete, build it again, delete.  Each time you'll do it different, each time you'll look something new up, or simply 'get' something in a way you didn't before. 

If you are a hotshot, and just want to have a read through to see if some tour guide/travel agent can really write good Django apps, you are most welcome, and most of all, please, please, please, send me your feedback.  I have sort of invented the logic side of it for myself, and may well have missed on best practices.  Sometimes I may just have been stupid as a rock.  Feel free to point that out, I would like this tutorial to be useful to someone.  I am aware that I have at times abandoned the DRY principal, but I have, especially with the views, done that in the hope that it helps newbies learn easier - trying to learn from tutorials where the constant drive was to make it follow the DRY principal too much made if hard for me, and I am sure other beginners, to learn. 

If any bit of it doesn't make sense, please let me know.  I'll try to help you out. 

Enough chit-chat, let's build our blog… 


Share |
Return To Contents Page  |  Next Page »

 

Thank you for visiting

This is my personal blog, but I try to write things that you may find interesting or useful.  I'm currently working on a six month long project digging into the elements that make a blog meaningful. For more on that, visit MEANINGFUL BLOG PROJECT page

You may want to know a little about me personally, so start at the about page. 

If you find some of what is here interesting, or you want to follow the project through, why not subscribe.

Tweet