Managing Context Metadata in Django-PGHistory: Solving the Persistence Problem

In this post you would learn how pghistory.context works and some of its gotchas that we faced at Diversio(thanks to Amal Raj B R who identified this) and how we adjusted our approach to avoid saving context metadata that is not relevant to the current business logic but is being carried over from a parent context.

What is pghistory.context?

pghistory.context is a decorator and a function that is part of the fantastic django-pghistory project. I would cover how we use django-pghistory in a separate post.

When django-pghistory is keeping track of changes to Django models, there are several instances where we want to include additional information with the tracked changes. This is where pghistory.context comes into picture to easily capture such metadata …

Designing a Life: Lessons from Benjamin Franklin

Before listening to How to Take Over the World's episode on Benjamin Franklin, my impression of him was limited to “kite, key, electricity.” Afterward, I realized he didn't just discover electricity -- he basically invented the blueprint for self-improvement, then actually lived it.

He wasn't just an inventor; he created institutions and actively built himself. And he did it in a way that it feels surprisingly relevant today, without losing his sense of humour.

Some things that stuck with me.

Benjamin Franklin: The Original Self-Made Person

He's the most literal example of self-made people. He didn't just bootstrap a career, he designed who he wanted to be and iterated toward it.

At one point in his life, he wrote out a list of 13 virtues. Things like …

Actionable Insights from Jeff Bezos' Interview at the DealBook Summit

Risk is often overestimated; opportunity is often underestimated.

Podcast: https://www.founderspodcast.com/episodes/374-rare-jeff-bezos-interview

YouTube: https://youtu.be/s71nJQqzYRQ

Build something that outlasts you

Since early days of Amazon Bezos was thinking long-term and was quite clear that he wanted to build a company that would outlast him.

Spotify's Daniel Ek shares a similar sentiment: Companies grow like children — initially they are a reflection of their creator, but over time they develops its own traits and characteristics.

Steve Jobs said something similar: You build a company that will stand for something a generation or two from now.

Follow your curiosity

One of his driving principles is "I wake up and follow my curiosity". Paul Graham calls curiosity the best guide for doing great work.

Instead of …

30-60-90 — Set Up Your Engineering Hires for Success

Week 1

  • Assign a buddy or mentor but avoid using a direct manager for this, as the person won't be that open and comfortable with their manager.

  • Less emphasis on paperwork, focus more on mission, impact, values and culture.

  • Set up an interactive onboarding task to keep them engaged from day 1.

  • Encourage them to ask questions, voice concerns, and share ideas openly. It's very important to teach them to not remain limited to DMs and become comfortable in public channels with the whole team.

  • Help them set up 1:1s with different members of the team

First month

  • Make sure their local set up is up and running.

  • Assign small tasks to them. This can be small bugfixes, features and any documentation update. Documentation update is …

uv and PEP 723

uv and PEP 723

I have recently started using uv a lot, specially for quick standalone scripts, most of these scripts are generated by various LLMs for different tasks. The biggest pain point I had with these scripts was to setup a virtual env, installing the packages and asking ChatGPT and other LLMs to give me requirements file/list.

uv changed that by utilizing PEP 723 and embedding these requirement inline to the script.

At Diversio, I frequently use GitHub Copilot a lot, and there I've added a small instruction to make sure it's embedding the requirements in the script itself.

When asked to generate a uv based Python script, at the very top of the file, insert an inline metadata block listing all external packages in …