Thursday 08 January 2009

Bleak and industrial, we're not and never will be

how to migrate a WordPress blog to Django

There is currently no utility to migrate existing blog content to django.

However, conversion of an existing WordPress blog is pretty straightforward.

Firstly, simply export the following tables from the WordPress database using phpMyAdmin

  • wp_posts
  • wp_comments
  • wp_terms
  • wp_term_taxonomy
  • wp_term_relationships

Import the tables into the django database.

Then run the following SQL statements which migrate posts, comments and categories and assume a WordPress 2.3 schema and a blank django blog. If you have already created content in django, minor changes will be needed. My WordPress blog only uses categories which simply get converted to django tags.

insert into blog_post
(id,
slug,
title,
pubdate,
moddate,
body,
draft,
closed)
select
wp_posts.id,
wp_posts.post_name,
wp_posts.post_title,
wp_posts.post_date_gmt,
wp_posts.post_modified_gmt,
wp_posts.post_content,
0,
0
from wp_posts
and post_type = 'post';

insert into comments_freecomment
(id,
content_type_id,
comment,
object_id,
person_name,
submit_date,
is_public,
ip_address,
approved,
site_id)
select
wp_comments.comment_id,
14,
wp_comments.comment_content,
wp_comments.comment_post_id,
wp_comments.comment_author,
wp_comments.comment_date_gmt,
1,
wp_comments.comment_author_ip,
wp_comments.comment_approved,
1
from wp_comments
where comment_approved = '1';

insert into blog_tag
(slug,
title,
description)
select
wp_terms.slug,
wp_terms.name,
wp_terms.name
from wp_terms;

insert into blog_post_tags
(post_id,
tag_id)
select
wp_term_relationships.object_id,
wp_terms.name
from wp_term_relationships, wp_term_taxonomy, wp_terms
where wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
and wp_term_taxonomy.term_id = wp_terms.term_id;

Finally, delete the WP_* tables from the django (and not the WordPress) database.

last django in London

The problem with installing typo is that, during the research for hints and tips to get the software installed, configured and running on a shared server environment at Bluehost, you Google across like-minded obsessives individuals who have also successfully installed typo in 30 seconds flat. These people are technical types who sneer at PHP and lie awake at night, worrying about Ruby's scalability. These geeks tend to be obsessive characters who have now tired of typo and have subsequently migrated to a brand new exciting platform called django. Django is a Python Web framework - not a blogging platform or a CMS - but you could use django to create your own perfect blogging platform. Django has a endearing, minimalist administration screen and although the finished product looks like a 1980's HTML page or the stripped down WordPress sandbox theme, it's pretty impressive for 10 minutes and 100 lines of Python and HTML. I was going to write a superb article, with lots of screenshots and poorly formatted code blocks, detailing all the obstacles I overcame before finally claiming success. However, as always, the very clever aforementioned people have already been there and done that. So, if you are interested in installing django on bluehost, consult this thread. One quick note: my preferred method of installing into a sub-directory failed (403 permission denied) so I used a sub-domain which worked fine. For a more generic django tutorial about how to create a project, add models and templates, read (and bookmark) this excellent article. This gentleman has a rare combination of technical skills and a brilliant, light hearted, humorous writing style. His site also serves as a brilliant example of the potential appearance and functionality of a django powered blog. In fact, if I could summon up the time and energy to master HTML, CSS and Python, I would create my very own unique, stylish and distinctive blog but I don't so I won't. I was about to say there was no Wordpress to Django import utility until I just discovered this. Am I the first blogger to have more blogs than published articles ?

WordPress 2.3 and Typo

I have upgraded this blog to the recently released WordPress 2.3. However, I have deep rooted concerns that the new tagging functionality will simply overload my tiny brain.

The WordPress upgrade went smoothly enough although the editor now reports a missing table (wp_post2cat) which is slightly irritating.

Also, I sense increasing disquiet amongst some long standing, intelligent and loyal WordPress users so I took the precaution of installing YABP (Yet Another Blog Platform). Please put your hands together and welcome Typo (powered by a delightful lady called 'Ruby on Rails').

Update: The Google Sitemap Generator plug-in was causing the error. The problem is resolved in the latest version.

a rush of blood

I'm not normally a sucker for these free, pyramid style, link exchange schemes to drive more traffic to your blog but as simply everyone is not just talking about it but actually doing it, I thought I'd better add BlogRush to this blog.

Now, I must hurry into town and join the lengthy queues at Northern Rock to withdraw my 1 million pounds life savings. To be honest, I think this media fuelled panic is a little overblown and as I have a contrarian investing style, I have just purchased £5,000 worth of NRK shares at £3.10 waiting for the 'dead cat bounce'. The shares are currently trading at £2.93, £2.80, £2.69...

life and times of two 'A' listers

I like Robert Scoble. While I don't always agree with him and I have a love-hate relationship with his laugh, his blog is worth reading and he posts some varied and interesting videos but one thing is obvious.

The guy has a real passion for technology and writing. On occasions, he is subjected to vitriolic comments, hurtful criticism and abuse that is completely unjustified but he calmly takes it all in his stride and rarely retaliates.

Scoble is a family man and has a lovely wife. Indeed, he is a very lucky man. As I recall, my wife didn't have the forethought and love to buy me an expensive digital camera hours before she went into labour. Inevitably, Scoble will be posting live updates of his wife's lengthy and arduous labour via Twitter. I'm surprised he isn't live streaming the whole event.

Another 'A' lister recently admitted to hospital was Dave Winer. Unfortunately, Dave repeatedly broke rule two, regaling us all with updates on his state of health.

3 September - The saga begins...

'Had to take a break, I got a really bad cold, the flu, not sure what -- but it knocked me down. I had a fever, nasty cough, wheezing, and it was getting worse so fast that I went to the emergency room at a Berkeley hospital, where they gave me something to control the cough and help me sleep, and today I feel much better.'

6 September - Our hopes are briefly raised. Don't laugh. This is a disease !

'Yesterday was the first feel-good day after a horrible bout with whatever it was that hit me and dragged me under. But Naked Jen, who said she had the same disease, warned against believing you're better when you start feeling better.'

8 September - Our hopes are dashed but at least Dave received my email of support.

'I've gotten email from people who are concerned. Thanks for the concern. Yes, I have seen a doctor, even went to the hospital to get chest x-rays. I don't have pneumonia. Just a realllly bad cold. A monster proportioned cold. It attacks everything but my sense of humor.'
9 September - My diagnosis is that this is not merely a heavy cold. This is a life threatening bout of man-flu.
'It's been a really interesting morning, in a sick kind of way (that is, I'm still really sick, coughing and wheezing, rasping and sneezing).'

10 September - Dave manages to summon the strength to type a blog post with no mention of his health.

11 September - A nation sighs with relief.

'Feeling much better today. Health is beginning to return. I owe it all to patience, lots of sleeping, drinking fluids, and not trying to be healthy before I actually am. Today I'm going to take a 20 minute easy walk in the sun.'
Winer by name. Whiner by nature.