Posts

Showing posts with the label django

Carefully Upgrading to Django 1.0

I’m a little behind, but I finally upgraded my family website to Django 1.0 . First of all, I wanted to keep the main site running my older version of django from subversion while having 1.0 installed and being used by the development version. First I added the old install to my apache configuration’s PythonPath. Here’s the diff: - PythonPath "['/home/bryan/web/murdockfamily'] + sys.path" + PythonPath "['/home/bryan/web/django_src', '/home/bryan/web/murdockfamily'] + sys.path" Then I deleted the symlinks to that django install from any site-packages locations: sudo rm /usr/lib/python2.4/site-packages/django /usr/lib/python2.5/site-packages/django /usr/local/lib/python2.5/site-packages/django Then reloaded apache: sudo /etc/init.d/apache2 reload And it seemed to still work. Next I untarred Django 1.0, and installed it: tar -zxvf /home/bryan/downloads/Django-1.0.tar.gz cd Django-1.0 python setup.py build sudo python s...

Convert a PostgreSQL Database from LATIN1 to UTF8

I had a problem with my family django-powered website. I have an aggregator for all our friends blogs, very similar to the Django aggregator , except that mine hasn’t been aggregating. After some serious investigation, I found that psycopg was barfing error messages because the feeds that were being stuffed into my postgresql database contained utf-8 characters that it couldn’t figure out how to convert into latin1 characters. I hadn’t paid any attention to this, but apparently my blog database was using latin1. Lame. I decided it was time to learn how to convert it to utf-8. First, I did a pg_dumpall in order to get a look at things (this happens automatically every night, actually): /usr/bin/pg_dumpall -U <special user> > /home/bryan/backups/all.dbs.out Sure enough, my database was created like so: CREATE DATABASE bryan WITH TEMPLATE = template0 OWNER = bryan ENCODING = 'LATIN1'; So, I dumped just that database: pg_dump -U <special use...

ReCAPTCHA and Django FreeComments

My little family blog has been discovered by spammers. They have started leaving comments on my Django powered blog. Not very often, but enough to be annoying. I heard about reCAPTCHA and thought it was a fabulous idea, so I decided that was how I wanted to up the ante for the spammers on my blog. Integrating reCAPTCHA with the Django freecomments wasn’t as easy as I thought it would be though, so I want to write down how I made it work in case it will help somebody else down the road. First of all, I did my due diligence and googled for help. I didn’t find much, but I found an email , a snippet , and a blog that got me going in the right direction. While I’m citing references here, I also made use of the comments page on the Django wiki , and the request and response documentation too. The reCAPTCHA api docs were vital as well. OK, after doing my reading googling I got to work. I registered for a set of reCAPTCHA keys, downloaded the recaptcha-clie...

Django Powered Sites

I guess I'm a little late finding out about this, but I'm excited I found my Django powered family website in the mosaic . C-11.

Django Does Gmail

I love it when I ponder something quietly to myself, not even uttering my question aloud, and then bump into an answer that same day by seemingly random bouncing around the internet (and let us not speak of the countless hours utterly wasted by bouncing around the internet at other times!). I don't check my feed reader enough to notice comments posted to my family website in a timely manner. I need more than just an RSS feed of recent comments. I need a higher priority interrupt. Email seems about right, but I don't think setting up sendmail (or something like unto it) is what I want. Emails from my home machine would probably be rejected as spam most places anyway. If only my Django powered website could send mail through gmail . And lo, the answer was there before me.

Fixed Django Powered Blog

OK, I figured out the problem with my Django powered blog . The new pg_hba.conf file had stricter permissions for local users. I had to change it from "ident sameuser" to "trust" and then my django app could connect to the database. I also had to make sure, after editing it as root, that the pg_hba.conf file was writable by the postgres user. Then I could /etc/init.d/postgresql-8.2 restart successfully, and everything works again. Oh wait, my php photo gallery is still down. Grrr!

Restore PostgreSQL

The magic command to restore my lost database , once I got my dump file out of my backup, was: sudo su postgres -c 'psql -f /home/bryan/backups/all.dbs.out postgres' My Django website still doesn't work though. Darn you, Ubuntu! (sorry for the harsh language)

Edgy to Feisty Horror

As mentioned previously, I upgraded my work machine to Feisty Fawn without much trouble, but waited on doing my home machine because I knew it would be a bit trickier. The reason is I run a family website from that machine. It's basically a blog built with Django and it uses a PostgreSQL database backend. It also has a photo gallery with tons of family photos. I would hate to lose either of those. I had a bunch of free time last night, and I had backed up important stuff to some DVDs recently, so I decided to go for it. I clicked upgrade in the Update Manager and off it went. About then a good friend of mine called. We hadn't talked for a long time, and we had a lot to catch up on. Perfect. I let the install run while we chatted. It was taking a while to progress, but I didn't think too much of it. After we hung up and said goodbye, I started reading a book. It was finally to the configuration and setup part and occasionally asked me some questions. I was e...