Friday, December 26, 2014

Best Django Boilerplate/Skeleton

This is my favorite boilerplate for new projects so far:


If you're not a fan of bootstrap, django-html5-boilerplate also looks good.

Thursday, December 11, 2014

Setting A WTForm Default Date To Today/Now

It's definitely a common mistake for people using WTForms. When you create a form and use something like as a default value, that value will always stay the same. The fix is to use "" instead of "".

Friday, December 5, 2014

Dokku Flask Port and Host

In your flask application, you need to:

  • Set default port=5000 (this seems to be Dokku's default too)
  • Set default host= (this allows your host server to connect to the container)

In your Procfile:
web: python <your-app>.py

If you're using gunicorn, it shouldn't matter because it's not using

If you still can't connect to your application after it deploys, see this:

Troubleshooting Dokku Not Accessible

First, make sure your application isn't giving any errors when it attempts to run:
dokku run <your-app> "<whatever is in your proc file>"

Get the :port number from the line with "upstream" in the following file: /home/dokku/<your-app>/nginx.conf

Try to "wget<your-port>" from the host. Will it connect?

Thursday, December 4, 2014

"Requested runtime not available for this stack" - Dokku

While using Dokku, I was getting the following error message: Requested runtime (python-2.7.8) is not available for this stack (cedar-14).

This was due to a connection error between my docker container and the internet. To determine this, I ran "docker images" and got the image id of "programium/buildstep", then got into a container with the following command: sudo docker run -t -i <your image id> /bin/bash

Once in the container, I ran:
curl -s

If that is unsuccessful, that should confirm it's a connection issue.

This was the solution to the problem:

Tuesday, December 2, 2014

Rebuilding Buildstep Image For Dokku From Behind Proxy

I had to change the buildstep image's docker file to add my proxy. This is because the buildstep image required a proxy before the build to download the python buildpack.

I was rebuilding the buildstep image for dokku with these instructions:

I'm behind a proxy, so I was getting this error when I ran "sudo make build":
Cloning into 'heroku-buildpack-multi'...
fatal: unable to access '': Failed to connect to port 443: Connection timed out

The solution? Replace the Dockerfile in the root of the folder you git cloned with this:

Monday, December 1, 2014

Troubleshooting Pip Timeout - Python

Timeout: (<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x27330d0>, 'Connection to timed out. (connect timeout=15)')

If you're installing several requirements from a requirements.txt file, it helps to use "-v" after your pip install command to figure out which module has the timeout. Most likely, it's trying to download a module from a URL that doesn't exist.