Blogs

Use Django view class for JSON/AJAX response.

Django’s documentation offers a working example of to create a class-based view to spit out JSON suitable for AJAX web app. This produces an easy-to-use way of responding with JSON.

https://docs.djangoproject.com/en/1.4/topics/class-based-views/

As far as I’m concerned it’s a good django-equivalent to Ruby on Rails render :xml.

Upgrading Drupal

I was trying to do some real work until I found out that my retardo-blog has been having some issues with PHP. This opened up a giant can of worms because now I want to move off of my shared host.

Get latest version of drupal.

wget http://ftp.drupal.org/files/projects/drupal-X.XX.tar.gz
tar xzf drupal-X.XX.tar.gz
cd drupal-X.XX

Copy the important directories from the old version

cp -r ../original/files .
cp -r ../original/sites .

Backup MySQL

mysqldump -u -p databasename > backup_drupal_X.XX.sql
mysql -u -p databasename < backup_drupal_X.XX.sql #restore

Swap in updated code

mv blog drupal-BACKUP
mv drupal-X.XX blog

Update and migrate system
http://example.com/update.php

Now update your modules.

Run update.php again for each module. It’s OK to update the modules in bunches.

Fix django-crowdsourcing

I was trying to use the django-crowdsourcing for an app that I was trying to put together I kept getting this error:

TypeError: can’t compare offset-naive and offset-aware datetimes

It turns out that there is a new concept for Django 1.4 timezones. To fix the problem you need to install some python libraries and replace use of the standard python datetime object.

terminal% pip install pytz
from django.utils import timezone

Look for

datetime.now()

Replace with

timezone.now()
Syndicate content