"Q: I have a team of scientists readying articles for our custom Django CMS with lots of numbers and attached units located in their contributions. I would like to offer visitors a way to switch between metric or imperial units.
————————————————————
A: This calls for a social solution: tell them that if they want imperial units they are Not Scientists. ;)"

turbines in antarctica

These are some wind turbines powering an Antarctic Research Station.  And that’s also about as South as you can get in your quest for renewable energy.  But today we’re writing about migrating your databases South!  Or the following scenario:

You create an übercool insightful Django model.  You put some data on it, make some templates, … looks good!  And then you realize it wasn’t as cool as you thought.  You forgot to add … say the minimum operating temperature for your wind turbines.  Bummer!  Enter South ( intelligent schema and data migration).

$ manage.py schemamigration app_name --initial
$ manage.py migrate app_name --fake
$ manage.py migrate app_name

Then edit your models.py and add all the fields you forgot to add,

Then create the new migration file and finally migrate the database:

$ manage.py schemamigration app_name --auto 
$ manage.py migrate app_name 

see also [djangopro] for a good explanation.

Vtiger is an open source CRM (Customer Relationship Management) platform.  Its purpose is to let you keep track of contacts, customers, mailing lists, as well as purchase orders, sales leads, create invoices, and a long etcetera.  One of its strengths lies in the abundance of extensions and plugins to make it talk to various technologies (Outlook, Firefox, Mobile, etc).

Webfaction is a hosting company which I find very useful. If you’re hosting for a while (3 - 5 yrs) it comes down to $5.5/mo - $6.6/mo … and it gives you the full  ssh access, easy install for lots of applications (django, drupal, wordpress, joomla, rails, turbogears, and many more).  But what I like most is that when you have a problem you usually get an insightful reply in 20mn.  And you can tell the tech support girl/guy is a geek who knows their stuff.  Kinda like this.  Anyway,

1. Create a Static/CGI/PHP-5.3 (let’s call it vtiger) from the control panel, which will result in,

~/webapps/vtiger/

beging created.

2. Create a “website” pointing some domain www.mydomain.com to the application (from the control panel). 

3. Create a fresh MySQL database and write down user/pwd.

4.  On the command line,

$ cd ~/webapps/vtiger/
$ wget "http://sourceforge.net/projects/vtigercrm/files/vtiger CRM 5.4.0/Core Product/vtigercrm-5.4.0.tar.gz"
$ tar zxf vtigercrm-5.4.0.tar.gz --strip 1

5. Now point your browser to www.mydomain.com.  If you see “hello world” then back to ~/webapps/vtiger/ and rename or delete index.html.  Now back to www.mydomain.com … which should start www.mydomain.com/install.php

6. From there on you should have a website like this one guiding you through every step.  Use the previous MySQL usr/pwd for the database settings, as well as webXXX.webfaction.com for the hostname (where XXX depends on your webfaction specifics).

7. That’s it!  Start adding lovely paying customers and useful friendly partners to your CRM! ;)

For the first time, the tech support at @ my host (webfaction ) feels like I’ve said “Shibboleet!”

  • alvaro: dude, .bash_profile adding, > export PYTHONPATH="/home/username/webapps/app_production/lib/python2.7/:$PYTHONPATH"
  • hannes: I already have this in my bash_profile. What about tail -f error_django_app.log
  • alvaro: hum, 2.24.223.4 - - [13/Apr/2012:10:49:37 +0200] "GET / HTTP/1.0" 500 538 "-" "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:11.0) Gecko/20100101 Firefox/11.0" and the error [Fri Apr 13 10:49:41 2012] [error] [client 127.0.0.1] os.environ['DJANGO_SETTINGS_MODULE'] = 'someapp.settings' activate_this
  • hannes: have you had this error? 'Try setting GEOIP_LIBRARY_PATH in your settings.' % lib_name)
  • [Fri Apr 13 11: 27:56 2012] [error] [client 127.0.0.1] GeoIPException: Could not find the GeoIP library (tried "GeoIP"). Try setting GEOIP_LIBRARY_PATH in your settings.
  • alvaro: man, it's late
  • hannes: ok. good night.
  • alvaro: good night.

Perhaps you need to migrate from your local machine to a server, or ship some flatpages to your mate on the other side of the world.  Here’s how

$ python manage.py dumpdata flatpages --indent=2 > ma_backup.json

To recover it somewhere else simply do:

$ python manage.py loaddata ma_backup.json
"/ CTRL-G"
— Firefox shortcut to visit a link without the mouse.  click the ’ or / key (start typing on the quick find link, hit Enter to follow the link).  If you want to move to the next link matching your string use Control-G.
"grep -l “some_string” a-directory/*.html"
— finds all htlm files in “a-directory/” which contain the string “some_string” inside them and outputs the list of files
[Flash 9 is required to listen to audio.]

coding laser focus with Daft Punk Aerodynamic

Played 118 times.
"python -c ‘import settings’ :)"