Launching toy prototype on Heroku!

I have been implementing few ideas in Django for past month or so but as exciting it might be to see your code working wonders on localhost, you really want to see it running live. Over last week, I explored various hosting options for Django and after reading a ton of posts and talking to few people, I picked Heroku. I also contemplated paying someone for it but I thought that investing a week in learning this is much more valuable and reusable than if I have to find and hire someone, explain my requirements (do it for every new project) and following up to make sure they are doing it right. Basically, it had come down to these 3 options-

  1. Webfaction – the de facto standard for a lot of python developers. It has good tutorials and seemed like the most straightforward guided hosting option.
  2. Linode – I talked to a friend who does professional django consulting and development and this is what he uses. But I figured that linode is more suited for professionals who know exactly how they want to setup their environment. Linode gives you most freedom if you know what you want but it can be overwhelming for novices. You are paying and you have to work.
  3. Heroku – the newcomer and the revered choice for rails application has finally embraced django. Heroku takes away all your hassles of configuring a prod environment and makes the deployment as easy as humanly possible. You are paying so that you work least. It does not mean it was all magical, you still need to understand what a good environment is and what are good prod practices. But I figured you need to learn those with any platform anyways, so why not invest some time in learning this growing service once and for all. It is probably very straightforward to people who have done it before (and I read a lot of pros switching to Heroku) but I spent 2 days figuring out minute details which even got frustrating at some points. But, in the end, I have a minimum working prototype up on web and I am loving it.

If I had to summarize past few weeks, it would be like this:

Get fairly comfortable with Django and already tried out few tutorials.
Learn the importance of good URLs.
How to start with minimal features and structure (urls) and fill out views later.
Always reuse opensource libraries – userena, imagekit etc.
Working with images can be a pain – getting PIL to work with jpeg was a nightmare but essential.
Understand the meaning and difference between static and media URLs (it took me unbelievably long time).
You are lucky to be developing in post twitter-bootstrap era. CSS will never have to be ugly now and anyone can design a professional looking web app.
Beauty of django ORM is that I can use mysql in dev and postgresql freely supported on heroku (use south for migrations).
Git is godsend, learn it asap.
Heroku needs virtualenv, so learn it.
Deploying my toy app on heroku cost me $0 so far (its non-persistent and slow but I don’t care right now). I can keep iterating and getting feedback from friends while adding those few missing components needed to launch the project live.
Internet has all the answers, just be persistent and think what is the right question.

The bottom line is learn whatever it takes to go live!

Anyways, here is my toy prototype live - http://smartbride.herokuapp.com/ (the picture links get broken in sometime due to non-persistence)
The fun has just begun, more updates soon.

Posted in Startup Life, Technology | Tagged , | 2 Comments

Regain your momentum

I got back from a long vacation and wanted to gain my momentum back on the project I’m working. So, I read through a bunch of articles and wanted to share these ones in particular-

1. How A Tiny Ohio Clothing Site’s Revenue Exploded From $5 To $50 Million In 1.5 Years
Read more: http://articles.businessinsider.com/2012-03-28/tech/31247889_1_brands-business-insider-thrillist#ixzz1qd2Rh3Bb

I loved the hustling part of the founder. I’m seeing a lot of success stories on fashion, retail kind of startups these days because it doesn’t require the tech expertise where many aspiring entrepreneurs get stuck + working smartly on back end of supply chains has been proved possible and ideas easy to market using Internet. Also, obviously these people love this space and its easy to get passionate about something you love.

2. How to thrive as a solo non-technical founder
http://weddinglovely.com/blog/how-to-survive-as-a-solo-designer-founder/

This is a great motivating read (read the links in between too) – showing that if the idea is simple enough, don’t waste time on finding a tech founder but just do it yourself. And reading this will make you realize why it’s important to be a cockroach.

3. Lastly, I read this more techie post on ‘Switching to Heroku: A Django App Story’ while researching how to deploy my test django app.
http://blog.sendhub.com/post/16800984141/switching-to-heroku-a-django-app-story
On same lines, Minimum Viable Ops – Deploying your first Django App to Amazon EC2 by Eddy Chan

It also led me to ask this Django question on Quora - http://t.co/RCdXZuR7

By the way, whenever I feel I’m losing steam, I do the same. Go to hacker news, business insider, tech crunch or whatever and read some great posts.

Ok, back to work now

Posted in Startup Life | 2 Comments

Setting up Django with MySql – with and without MAMP

In this post, we will discuss the steps needed to get your django work with mysql database  on Mac OS Lion – there are 2 ways you can use mysql. It comes packaged with MAMP and if you are already using it, you can configure mysql within MAMP to get running with django. The advantage is MAMP’s front end controls and built in phpmyadmin. Otherwise, you can install both mysql and phpmyadmin fresh.

But before that, you should install python and django as covered nicely in Django Book. What it doesn’t cover in detail is getting the database setup, so refer to the following once you reach ‘Setting up the database’ section.

  1. First, we need MySQL server. If you already have MAMP installed, you dont need this step, skip over to next. If you dont, lets install MySQL community server from http://dev.mysql.com/downloads/mysql/ I downloaded the then latest mysql-5.5.20-osx10.6-x86_64.dmg and followed the instructions. If you set the preferences correctly in Startup Package and Preferences Pane (double click MySQLStartupItem.pkg and then MySQL.prefPane), you can configure mysql to be started/stopped from System Preferences. We did this to have easy controls to start and stop mysql.
  2. Setup mysql-python package- Although you have installed mysql, we need MySQLdb package to allow it to work with python. I have heard you can use pip or easy_install to install this package easilybut it can start giving errors sometime. So, here is the longer route but one which I have successfully tried and hopefully you can too. First, get mysql developer package to have all the files-
    • From the same mysql download url, download the latest tar.gz package (version should be same as the dmg file you downloaded in step 1). Put it in your home dir and execute following command-cd ~; tar -xvzf mysql-5.5.20-osx10.6-x86_64.tar.gz
    • This will create a dir called mysql-5.5.20-osx10.6-x86_64. Copy this dir over to /usr/local using the command sudo cp -r mysql-5.5.20-osx10.6-x86_64 /usr/local/
    • Now, rename this dir in /usr/local to mysql using
      sudo mv -r /usr/local/mysql-5.5.20-osx10.6-x86_64 /usr/local/mysql
      With this, we have created a hard copy of our latest mysql. If you upgrade your mysql in future, follow the same steps. Alternatively, you can create a symlink too.
    • Add this to your .bash_profile (created in previous post in your home dir) so that your system will know where to find mysql related files -
      export PATH=$PATH:/usr/local/mysql/bin

    Next, install mysql-python package-

    • Download the latest MySQL-python package from http://sourceforge.net/projects/mysql-python/files/mysql-python/ to your home dir
      Execute following commands-
      cd ~; tar -xvzf MySQL-python-1.2.3.tar.gz
      cd MySQL-python-1.2.3
    • Edit site.cfg on vi and change the mysql path as follows
      mysql_config = /usr/local/mysql/bin/mysql_config
    • Lets build and install MySQL-python package now:
      sudo python setup.py build
      sudo python setup.py install
    • IMPORTANT: Edit your ~/.bash_profile, add the following line:
      export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
  3. Lets test our setup to make sure everything is working as expected-
    On terminal, type python to start python shell. On python shell, type ‘import MySQLdb’. If you see no errors, you are good to go!

The steps 2-3 are required both with and without MAMP. Next, few helpful things-

  1. with MAMP – if you have MAMP, you already have phpMyAdmin installed and instead of starting MySql through system preferences, you can control it from MAMP interface. Further, I have these in my .bash_profile to use mysql from MAMP-
    alias mysql=/Applications/MAMP/Library/bin/mysql
    alias mysql_config=/Applications/MAMP/Library/bin/mysql_config
    Other thing to note, when you will setup your own django project, use this in settings.py -’HOST’: ‘/Applications/MAMP/tmp/mysql/mysql.sock’
  2. without MAMP – lets install phpMyAdmin to manage our mysql server using instructions given here. I tried and it worked great, so I dont want to duplicate the efforts. Lastly, in your settings.py, you will leave ‘HOST’ empty when you setup your own django project.

So, are there any particular advantage of using mysql with or without MAMP? – I dont think so. I used both of them and did not feel any difference worth worrying over. So, take your pick – if you have MAMP, use it. If you dont, you definitely dont need it for django.

See previous article on Getting started to code with Python/Django - Learn Python/Django and get ready to launch your own idea on Internet

In next and last article, I will post how I learned the rest and got to build my own django app.

Posted in Technology | Tagged , , | Leave a comment