The Idea
At work, some of us are really thinking hard on different ways that we can improve the hiring process. One of the ways is revamping some of the questions that we ask candidates. With that in mind, a buddy on my team and I got to work. One of our thoughts was to make something that was still really easy, but better than standard academic style questions for managing lists/arrays.
We decided to create a couple of endpoints that return a JSON response with data that can be sorted, merged, paginated, etc. I took the opportunity provided by needing to make a toy application and decided that I would build my first Django application (bare as it would be), use PostgreSQL for the first time, and host my first application on Heroku.
Pain Points
Django so far is awesome. And I’m really impressed by what Heroku has going on. I followed the directions on the Heroku site line by line and quickly had a ‘hello world’ page up. However, there were some issues.
First, getting PostgreSQL going for the first time was a bit frustrating. Their ‘Getting Started’ docs are a little light on some super basic info that I did not have. I install the software on my Ubuntu system. Cool. I go to create a database and table using the command line and … BAM. Can’t be done. I don’t have a role for my system username. Ok, so I search PostgreSQL’s docs for adding roles. No problem, I just need to run some direct SQL. Well, and it is probably me, I could not find anything on what the actual command line was to open PostgreSQL. After some Googling, I discover that it is simply the psql command. Cool. I enter it. Role problems still. Well. Hmph. After some sleuthing and more doc reading, I realize that I have to go in with the Postres user. a ‘sudo -su postgres’ later and now I can add the role for my username and be free to use ‘psql’ from the command line in a sane fashion. Sheesh.
Second, Heroku. I get the models set up for my Django app. Everything looks good on my dev side. I push up to Heroku. I realize that I need to run a dbsync. I do that locally and it explodes. Engine issues. I realize that the tutorial from Heroku had me overwrite the database settings for Django and that seems to be the problem. After some more digging, I realize how to set the default database info for Django in accordance with Heroku’s added code. Everything seems to be working. Push up to Heroku. No go. Hmm. It took some more time to realize that I have to manually set the DATABASE_URL environmental config for Heroku. Heroku provides the database info in a different config variable. If they would have mentioned it in the setup docs, this would not have been such a royal pain in my ass. Not quite thirdly, one solution that I tried to explore had me run ‘heroku addon….’ To which the heroku application said there is no ‘addon’ command, and offered that perhaps I mean ‘addon’ instead. WAT?
All’s Well that Ends Well
While there was the pain points, I’m all up and going and more wiser than before. It would have been a whole lot less frustrating though had Heroku and PostgreSQL had just a tad more documentation. A few minutes on their part would have saved me a metric-tonne of time.