Tips for developing Python apps for Heroku on Windows

This tutorial assumes you have a Heroku account, aren’t super-familiar with Django, and are working on Windows 10.

Start with this tutorial.

You’ll also want to follow these instructions.

I also recommend installing PGAdmin if you want a GUI interface to manage your database.

Key commands

You’ll want to create a separate .env file. I called mine .env.dev. Be sure to add that file to your .gitignore

To start your local instance with your customized .env file run this (make sure you cd into the folder where the app is located):

heroku local web -e .env.dev -f Procfile.windows

Commits

git add . && git commit -m "your message"
git push heroku main

Database changes

To keep your local database in sync with Heroku, you’ll need to run the same commands in each environment

Local

python manage.py makemigrations
python manage.py migrate

Remote

heroku run python manage.py makemigrations
heroku run python manage.py migrate 

Reset your sequence

If you copy data from local to remote, your sequences will get messed up. Here’s help on resolving.

select max(id) from "whiskeydiary_whiskey";
select nextval('"whiskeydiary_whiskey_id_seq"');
select setval(pg_get_serial_sequence('"whiskeydiary_whiskey"', 'id'), max(id)) from "whiskeydiary_whiskey";
select max(id) from "whiskeydiary_distillery";
select nextval('"whiskeydiary_distillery_id_seq"');
select setval(pg_get_serial_sequence('"whiskeydiary_distillery"', 'id'), max(id)) from "whiskeydiary_distillery";
select max(id) from "whiskeydiary_whiskeyinstance";
select nextval('"whiskeydiary_whiskeyinstance_id_seq"');
select setval(pg_get_serial_sequence('"whiskeydiary_whiskeyinstance"', 'id'), max(id)) from "whiskeydiary_whiskeyinstance";

My stuff

In the spirit of Uses This here is an overview of the stuff I use for coding, writing, and research.

Hardware

  • I have a Lenovo Legion Y530-15ICH with 8GB RAM running Windows 10.
  • I have an HP Notebook 14-an012nr running Ubuntu with 4GB RAM
  • My work laptop is an HP EliteBook 840 with 8GB RAM running Windows 10
  • I have a dual monitor setup – an HP 27ES and an LG Flatron E2350V. I hook one monitor to the Lenovo on HDMI and the other using a Benfei adapter that connects the HDMI to the MiniDisplayPort input on the laptop.
  • For scanning and printing I have an Epson XP-420.

Software

  • On the Lenovo, I use Office 365 including Teams for collaborating with coworkers. For development I have WSL running Ubuntu with a LAMP stack. This is where I develop before pushing code to the website. I use VSCode . I recently install dbForge studio for direct database access.
  • My WSL server didn’t have all the dependencies I needed to get Jekyll to run and I got tired of searching for ways to get it work. So I installed bundler and Jekyll on the HP notebook and now use that as my development area for my whiskey journal on GitHub pages.

Workspace

Due to a conicidentally timed renovation of my normal workplace, I have been working from home full-time since March 6. With the current statewide stay-at-home order, I will likely remain working from home until at least mid-April. I have been making the best of it, setting up a reasonably comfortable and ergonomically friendly workspace. I owe a debt of gratitude to Austin Kleon and one of his books (not sure if it was Show Your Work or Steal Like an Artist) for the idea of having separate digital and analog work areas. Here’s an interview where he describes it. My analog work area is a drafting board my father-in-law used to use. I raised it up so I could stand while I work.

My corona virus quarantine work space.
This angle gives a better view of the analog workspace. And by analog workspace, I mean a place where I stand and doodle and cut random objects out of old maps, books, and magazines.

Miscellaneous

My other tools:

  • My phone is a Motorola Z2 Play. It’s reliable and has good battery life. I make my last payment on it next month. I’ll probably hang onto it for awhile.
  • I use Player FM to listen to podcasts.
  • Thanks to my eldest son-in-law, I have access to Spotify Premium for downloading music.

… speaking of music (digital)

  • iHome bluetooth speaker
  • Dylan Marathon 2 wireless headset for exercising and walking the dog

Music (analog)

  • Kenwood KD-67F turntable
  • Sony STR-DE597 receiver that I bought at Circuit City (LOL) in 2004 for a little less than $200
  • I have two sets of speakers: Technics SB-K25 that I bought in high school and a more recent pair of Sony SS-MB150H.

Photos identified

One nice thing about throwing stuff on the internet is sometimes someone looks at it.

Last week I got an email from the grandson of the mystery couple in this picture:

The man in front is Fred J. Ackermann, RPh, and the woman on the left is Helen Campbell Ackermann. Fred was the pharmacist and partner of my grandfather Walter Coulter in the restaurant and pharmacy at the corner of Sloane and Detroit in Lakewood, Ohio. He also confirmed my assumption that the other couple are my grandparents.

Measure for Measure

“If the old fantastical Duke of dark corners had been at home, he had lived.”

Act IV Scene iii

My year of (not) reading

2018 wasn’t a great year for reading as my Goodreads reading challenge shows.

Last year was the first year I had a tablet, which I thought would increase my reading time. Paradoxically it only encouraged me to download a lot of public domain books that I skimmed but never finished.

Also, I listened to few audio books last year.

2019 will be better. Or not.

Walter Coulter 1918-1983

The Coulter family moved to Lakewood, Ohio, from Wayne County in the early 1900s. They opened a drug store and restaurant at the corner of Detroit and Sloane in 1907.

Walter Coulter was born on September 9, 1918. He grew up in the family business. His proficiency in the kitchen made him a natural candidate to be a cook in the army.

Walter married Helen Kennedy on September 20, 1941. Their three children were born in 1943, 1955, and 1965.

Sticky Fingers

Sticky Fingers: The Life and Times of Jann Wenner and Rolling Stone MagazineSticky Fingers: The Life and Times of Jann Wenner and Rolling Stone Magazine by Joe Hagan
My rating: 3 of 5 stars

The life that Jann Wenner lives is a caricature of the Baby Boomer generation: hope and idealism in the ‘60s fostered by pot, LSD, and the Beatles. Then cynicism in the ‘70s in the wake of Watergate and Vietnam. The ‘80s brought cocaine and the lure of easy money on Wall Street. Then booze and glamorous vacations in the ‘90s and beyond.

Joe Hagan gives all that in Sticky Fingers, along with fabulous tales of Hunter S. Thompson, Tom Wolfe, Cameron Crowe, Annie Leibovitz, John and Yoko, Mick Jagger, and a cast of A-list celebrities. One thing that’s missing is any sense of an interior life. You get the sense Jann Wenner doesn’t have one. And you might be right.

A bio of Jann’s long-suffering wife Jane might have the gossip and glitz plus some actual emotion. Would be interesting to find out.

View all my reviews

Getting a 404 in Vagrant?

Are you continually getting a 404 warning after vagrant up?

The following line in your vagrantfile should do the trick:

Vagrant::DEFAULT_SERVER_URL.replace('https://vagrantcloud.com')

Thanks to  Val on github for the tip.