Django: Testing for Missing Migrations

When adding or altering model schemas in Django, developers typically generate and commit accompanying migration files. But, counterintuitively, Django wants to track all model changes in migration files, even if they don’t result in database schema changes. Those can be easy to miss.

Regardless the reason, you never want your repo to be in a state where migrations are detected as needed, but accompanying migration files aren’t committed.

Writing a pytest test that can be triggered on github, Circle, Travis, Jenkins, or whatever you use turns out to be trivial, but I couldn’t find documentation or examples on the interwebs, so am posting this here for posterity:

import pytest

from django.core.management import call_command

@pytest.mark.django_db
def test_for_missing_migrations():
    """ If no migrations are detected as needed, `result`
    will be `None`. In all other cases, the call will fail,
    alerting your team that someone is trying to make a
    change that requires a migration and that migration is
    absent.
    """

    result = call_command("makemigrations", check=True, dry_run=True)
    assert not result

It really is that simple! If no migrations are needed, result will be None. Any other return value means someone should run ./manage.py makemigrations to see what’s missing, and commit the results.

El Radio Fantastique

Cycling Pt. Reyes/Petaluma today, stopped off to check out a trailhead I hadn’t seen before, when suddenly I heard a band. Just over the hill, this family – Mom and Dad and two daughters – shooting a music video out in the middle of nowhere. “El Radio Fantastique” they call themselves. As Beefheart said, “Practice in front of a bush.”

Felt a bit embarrassed when I realized too late that they were in the middle of filming a music video – I had thought the guy with the smartphone was another hiker surprised to find a band playing on the trail! My apologies to the band if I interrupted your creative flow.

More about the band here.
Listen on Apple Music here.

In Defense of Flickr

Update: This post has been substantially updated and re-posted as the Medium article “Flickr Is No Ghost Town” – please read that version instead of this one!


Original post:

People like to say flip things like “Flickr is dead” just like they’ve been saying “Apple is dead” for decades. It’s true that Flickr’s heyday has passed, but there are still hundreds of thousands (millions?) of photographers posting there daily. Interaction is lively, there’s an interest group for every photography niche you can think of, and users are really supportive with the compliments and CC. Flickr still has upwards of 75 million accounts, and can receive up to 25 million photo uploads on a good day (stats).

Sunset at Berkeley Marina

Flickr dominated the online photo sharing scene for around 15 years. But as Facebook’s popularity rose, FB became the world’s dominant photo sharing platform, eclipsing Flickr’s numbers (which were already astounding). After a recent brush with financial ruin, Flickr was purchased by SmugMug, and they’ve been great stewards of the platform so far, with improvements being released on the regular.

Sunset at Berkeley Marina

Somewhere in there, along came Instagram to soak up much of the remaining photographic juice in the room. Everyone is on it, so you’d be nuts not to use it, right? I use it too.

So why not just use Facebook and Instagram and call it a day? A bunch of reasons!:

  • Instagram images are tiny postage stamp versions of the images you’ve put so much work into. It’s almost an insult to your photos to display them so small with no full-size web option. But we all do it because we have to (and it’s fun).
  • Instagram has hashtags, but no real “groups” – no organized photo communities.
  • Facebook does full-screen, but they still compress and rewrite your images on upload, even if you enable the HD mobile setting.
  • Not everyone is on Facebook. Millions of people won’t use it for either personal or political reasons (I’m sure we’ve all seen numerous friends leave the platform in the past couple of years). People without FB accounts simply can’t see your work here. Out of bounds. Walled gardens have their place, but I don’t want my photos in one.
  • What if you decide to leave Facebook in a couple of years? What happens to all the work you posted here? Or will the fact that your photos are on FB prevent you from leaving the service even if you want to for other reasons? You’re “locked in.” Putting your images on Flickr instead means your images are decoupled from your social network, which gives you freedom.
  • Both Facebook and Instagram strip out all of your EXIF data, while Flickr does not. I really enjoy studying the EXIF data for other people’s images, or reminding myself of settings that were used on my own.
  • Only Flickr provides full and detailed statistics — not just of likes, but for all views, since the beginning of time (just realized my account is coming up on one million total views since I started there in 2005, wow!)

On Flickr, your images are available in super high resolution, with a wide variety of copyright options. There’s a huge number of interest groups, and detailed statistics. The challenge of getting an image into “Explore” (Flickr’s homepage featuring the best images on the service, changing constantly) is ongoing, and so rewarding when it happens. Discovering great new photographers daily is inspirational. Flickr is photo paradise to this day, IMHO.

Protester returning home, El Cerrito

All of which makes me wonder why so many photographers I meet aren’t using it. It seems like the best of all the options (yes there are other options, but they don’t compete with Flickr IMO, except maybe SmugMug (I’m curious about the features and community there too, honestly – promising).

Tower of Power

Are you on Flickr? And if not, why not?

FWIW #1: I usually post the same image to Instagram and Flickr at the same time, but only share the URL of the Flickr version, since it’s high-res. I only post images on Facebook occasionally, and just for the audience of my friends, rather than for the photo community.

FWIW #2: No I’m not a Flickr employee! Just a long-time user who never fell out of love.

FWIW #3: I’m shacker on Flickr and would love to follow you if you’re there too.

COVID-19 shopper at Trader Joe’s

Six Reasons To Use Apple Music Rather Than Spotify

This is a radically shortened version of my Medium piece Spotify vs. Apple Music (Why I Can’t Switch)

I see Apple Music as having six major advantages over Spotify:

  • Better audio quality (but not by a landslide). This is not just my subjective impression – Google it for verification.
  • 100,000 track max library size, compared to 10,000 at Spotify (that’s a deal breaker for me – I could not even fit my “favorite tracks” into a Spotify library).
  • Full-screen album covers instead of being forced to view tiny thumbnails (sorry, but cover art is really important to me, maybe I’m just old school). Though in the switch from iTunes to Music, cover art is now limited to 600px square, unfortunately.
  • Freaking amazing query-based playlists (Smart Playlists). Spotify has nothing comparable.
  • Ability to switch any view between Songs view, Albums view, Playlist view. IOTW you can view a Playlist as a collection of the albums they come from, etc.
  • Vastly superior/easy to use integration of all of your out of print or manually digitized audio content into your cloud space. Spotify makes this difficult if not impossible. This is a deal breaker for people who spent years digitizing their LP and CD collections.

For me, it’s just no contest. I tried Spotify for a month and found it pretty lame in comparison, given that the pricing is pretty much identical. AM gives you a lot more for your money.

Beyond vs. Impossible — Fake Meat Taste Test

Used to be that Beyond meats were available in the grocery store, but you had to go to a restaurant to try Impossible Burgers. But recently I found Beyond and Impossible side-by-side in the grocery store, and bought one of each. Last night I set up a little taste comparison test for family.

These modern fake meats are so delicious, it’s hard to find a reason to justify the eco- and health costs of buying real hamburger anymore.

Setup: Two patties the same size. Added the same amount of salt and pepper to each, grilled them at same temperature for the same length of time (3 mins/side). We tasted them as-is: No condiments or extras to get in the way of taste.

Impossible on the left, Beyond on the right.

My wife and son didn’t know which patty was which. To make things fair for my own opinion, I left the room and asked them to flip a coin to decide whether to switch the labels on the plates or not.

Conclusion: We all thought Impossible was slightly sweeter, and sure enough, the label shows that it contains a bit of sugar. We all though Beyond was slightly more chewy, and sure enough, it turns out to contain a bit more fat. Impossible had a bit more native seasoning – a flavor that’s hard to put your finger on, but good. Impossible was also more reddish in color (beet juice, right?) but Beyond had a slightly more realistic taste, if that’s what you’re going for.

At the end of the sampling, we all agreed that if a store had both and they cost roughly the same, we would choose Beyond over Impossible (consensus!). We thought Beyond was more delicious by a shade, despite the fact that Impossible has more seasoning built in. But both are delicious, and it’s gotten really hard to justify the eco- and health-costs of buying hamburger meat when products like these are available.

Honest Photography

Almost no one posts images straight out of the camera (SOOC) — there’s always work to do, improvements to be made. But how far can you go before crossing an ethical line?

As our photo editing tools grow artificial intelligence, and tricks that used to be difficult become progressively easier to pull off, photography forums continue to erupt in debates over what kinds of edits cross the line from acceptable and unacceptable? How far can you before an image becomes untrue? I just posted this in the /photography subreddit, on a topic titled “No It’s Not Cheating“:

There is only one question that matters as far as I’m concerned (but several ways to ask it): Is this an honest photograph? And by that I mean “Is the viewer being intentionally deceived?

If you convert to b/w, the viewer is not deceived. If you add a frame the viewer is not deceived. If you focus stack, the viewer is not deceived. If you modify saturation or contrast, the viewer is not deceived.

On the other hand, If you remove a blemish from a human face the viewer IS deceived. If you replace out the sky, the viewer IS deceived. If you change skin tone in such a way as to misrepresent, or “heal” out a passing airplane, the viewer IS deceived.

The difference between acceptable and unacceptable editing is easy when looked at this way. Does this photograph still tell the truth, or does it now tell a lie? Am I attempting to deceive or not? For me, this makes it easy to tell the difference.

I’m shacker on Flickr and Instagram if you want to follow along.

Bird in a Bush

The “doldrums” describes the area around the equator where wind sometimes doesn’t blow for weeks, and sailors get stuck, motionless, for long periods of time. Was just thinking about how being on lockdown is kind of like getting stuck in the doldrums. At least we can still get out to exercise, and we have entertainment, but the motion of life is pretty much on hold and out of our hands. Imagine what it was like to be a sailor stuck in the doldrums at any point in the past millennium, just staring out to sea, making up head games to pass the time. We’ve got it good. Maybe it’s time to write a new shanty.

Meanwhile I’ve been doing a lot of photography, and a lot of messing with photo tools and apps, just exploring and experimenting. Yesterday I spotted this little bird in a bush while out walking the dog, and later did this treatment of it in BeCasso.

Sync’ing Photos Between Computer and Phone (etc.)

Here are a few questions that come up over and over on photo forums. To me, these all amount to the same question. Or, at least they all have the same answer:

  • How can I post photos from my DSLR to Instagram (how to get DSLR images onto my phone?)
  • I have a computer, a phone, and a tablet. How can I transfer images between them?
  • If I delete or edit a photo on one device, how can I get those changes over to my other device?
  • “What do you all use for storage? An external hard drive?”

They’re good questions, and every new photographer has come up against them at some point. What surprises me is how many seasoned photographers still don’t have a good answer to them — surprising because I consider them a totally solved problem.

It’s 2020. All of your photos should live happily together in one library. That library should live in the cloud, so that when you add to or delete from or edit an image on one of your devices, that change is reflected on all of your devices. When you add an image from your DSLR to your photo collection, it should appear on your phone a few seconds later, ready to post to Instagram or whatever. You shouldn’t have to think about it – it should just work.

Equally important: No one should be having to keep photos in a bare folder somewhere, then drag them into Photoshop or Lightroom or whatever. All (pretty much all?) editing should happen directly in your Digital Asset Manager (DAM) – the tool you use to organize your photos into albums, and give them titles and descriptions and tags, to do all of your editing, organizing, sifting, sorting, importing and exporting to and from.

As far as I can tell, the best-integrated solution for this “one shared backing store” workflow is iCloud Photo Library from Apple. It works inside the Photos apps for MacOS and iOS, but changes the storage arrangement so that “master” copy of each image lives in the cloud, not on your hard drive (of course you must download the full-resolution master image to edit them, but that is a seamless process.

This makes some people feel nervous. We’re so used to controlling and backing up our own hard drives, it can be hard to hand over control. But think about it for a minute: How susceptible is your hard drive to fire, theft, or flood? How religious are you about backing it up? If you’re backing up off-site, what are you paying for that service? Do you really trust your little $100 hard drive and your own habits more than you trust a company holding the fate of hundreds of thousands of photographers’ work in their hands? If they made a mistake that bad, they’d be out of business. You can bet their backups are taken many times a day and distributed around the globe. And if you delete something by accident, you have a 30-day rolling Trash Can to fall back on. Seriously, I feel way safer with my photos in Apple’s hands than I did before.

At the risk of sounding like a fanboy, it’s hard to overstate just how liberating it is to have all of your synchronization issues just go away one day. The questions at the top of the page are just no longer questions. Use it for a few days and you’ll never want to go back.

$10/month, or $15/month for your whole family, is chicken scratch — you can hardly buy lunch for $10 these days. Great how-to guide here.

I jumped into iCloud Photo Library the day it was released and it solved all of the multi-camera / multi-computer problems I’d been banging my head against for years.

Other Options?

If you’re worried that the Photos app won’t be good enough to replace Lightroom, you might want to have another look at the the advanced editing tools in Photos — they’re extremely good! (I’d be curious to know whether there’s still anything you can do in Lightroom that you can’t do in the free Photos app?). Plus Photos supports plugins — I run Skylum Luminar not as a standalone app, but as a plugin for the Photos app. It’s mind-blowing what Luminar can do.

I believe that Windows users can also use iCloud Photo Library, but the integration workflow is a little less elegant. If you use Photo Library on Windows, please leave a comment and let us know what you think.

If you just feel super-married to Lightroom, the good news is that they now offer a cloud storage option as well, but I have no idea whether or how well it integrates with the Photos collection on your iOS or Android phone (if you know, let us know?)

Bottom line for me: Life is too short to be messing around with some of the convoluted workarounds people come up with to post their DSLR images on Instagram, or to deal with any of the other questions up top. You shouldn’t have to think about it – it should just work!

Remembering Rowan Jimenez

In the summer of 2016, I asked who wanted to try riding the Morro Bay Lighthouse Century with me in October (100-mile bike ride up the Pacific Coast Highway) . Rowan raised his hand and told me that the ride would mark the anniversary of his double lung transplant, and that he liked to celebrate each anniversary by doing something physically difficult — it was his way of showing that not only had he stayed alive against the odds, but that he was fully embracing life, living every experience to the max.

On Black Hill in Morro Bay with Rowan
Rowan riding up from Fairfax

Our kids had gone through elementary school together, but I’d never really gotten to know him. Over the next few months, we did a series of training rides together, all over the East Bay, plus an unforgettable climb to the top of Mt. Tamalpais in dense fog. In the course of those rides, through all kinds of weather, through intense sweat and crazy descents, I got to know Rowan and was blown away daily by his relentless joy and optimism, his profound appreciation for his lung donor, and for the second chance at life he’d been gifted. Rowan became a sort of role model for me, an example of how we all ought to be living.

After finishing the hardest part of the Morro Bay Lighthouse Century, with Rowan and Jim.

That October, we traveled to Morro Bay together and shared a hotel, then rode with another friend the next morning. Rowan wasn’t the fastest guy on the course – he was riding with the lungs of a 16-year-old girl! – but he was steady and determined, and there was never any question that he’d finish. The minute his odometer rolled over to that 100-mile mark, we stopped and high-fived each other and he let out a huge whoop of joy.

Rowan on Mt. Tam

When I heard the news today that Rowan had passed, I broke down in my wife’s arms. This cruel world has taken one of our brightest beacons. I’ll remember you forever Rowan – thanks for sharing that incredible adventure with me, and for sharing your bounty of optimism with all of us.

Rowan on one of our training rides

Oh my zsh

That version of bash we’ve been using on MacOS since forever hasn’t been updated since forever (for GPL licensing reasons). With Catalina, Apple finally got with the program and pushed bash into the background in favor of zsh. Nothing earth-shattering there – zsh has been available forever, but now it’s the default, and the Terminal will bug you on every launch if you don’t follow its instructions to migrate.

Once you do move over, run don’t walk to Oh My Zsh for a wonderful rabbit hole of themes, plugins, and configuration options to make zsh sing for you. By default, it knows how to detect whether the current directory contains a git checkout, and will show the active branch in the prompt, which is worth the price of admission alone.