frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

How to Use UUIDv7 in Python, Django and PostgreSQL

https://www.paulox.net//2025/11/14/how-to-use-uuidv7-in-python-django-and-postgresql/
12•pauloxnet•2mo ago

Comments

rekabis•2mo ago
Having software create the UUID is, IMO, more problematic than letting the DB create it itself as a part of its autogeneration for that identity column. Not the least because of any latency issues between a backend and the DB itself, if the DB is safely isolated from world+dog on a separate server that is only accessible by the backend.

It gets even worse if more than one backend has the ability to create entires that need to be in precise chronological order, either inserted “immediately” to a master DB or via eventual consistency through geographically distributed backends+DBs.

Sure, you can also use separate timestamp columns, but the timestamp portion of v7 appears to be sufficient for most use cases anyhow -- why have redundant data?

I believe I have recently bookmarked a trigger for MSSQL Server that is meant to autogenerate a UUIDv7 for an identity column, will try to link here later if anyone signals interest.

pauloxnet•2mo ago
Thanks for the comment. In the article I actually show both approaches: Python 3.14’s uuid.uuid7() first, mostly for completeness, and then the recommended one where PostgreSQL 18 generates the UUIDv7 itself using the native uuidv7() function. The DB-side version is already the default path I suggest for anything beyond a simple local setup.

Regarding the timestamp, a dedicated column generated by the database from uuid_extract_timestamp() can be very practical in Django. It is written at insert time by PostgreSQL, defined declaratively in the model with GeneratedField, and handled entirely by the ORM without relying on triggers. It also makes filtering, ordering or using the Django admin faster and simpler, since querying on a proper datetime field avoids extra annotations or computation on the UUID expression.

If you have a reference for UUIDv7 support in MSSQL I’d really appreciate it, ideally from the official documentation. I’m also curious to know from which version it is available and whether the current Django MSSQL backend exposes it already.

rekabis•2mo ago
>If you have a reference for UUIDv7 support in MSSQL

There isn’t any AFAIK. What I ran across was SQL that was meant to go into a trigger or something like that to generate a proper UUIDv7 as if MSSQL was creating one.

Hmmm… could have sworn it was featured here on HN, could have sworn I saw it within the last six months, could have sworn I bookmarked it for closer examination. Not finding it in my favourited stories here on HN, and I have even double-checked on Reddit and Lemmy - no bueno. Really frustrating me, because I love UUIDs for their resistance to the incrementing attacks that integer primary keys typically suffer from.

Edit: After a brief Google search this tickles my memory, but not entirely sure if it is the same code I remember looking at: https://github.com/osexpert/GuidPhantom/blob/main/Uuid_v7_v8...

sscherfke•2mo ago
I think it depends on the use case. When strict ordering of records from multiple processes is not super important and when you also need the UUID7 for other things, it may be more practical (and/or performant) to let the client compute the UUID7.

So, as usual, “it depends”. ;-)

pauloxnet•2mo ago
I’ve just updated the article with several clarifications and an additional section based on the feedback received yesterday. Thanks to everyone who contributed suggestions!
sscherfke•2mo ago
If you want to a UUIDv7 key for partitioning your table by date (e.g., one partition per day or month), you need to be able to compute the partition range via the minimal UUIDv7 for a given date.

There is some discussion whether or not to add helpers for this to Python‘s uuid7 module: https://github.com/python/cpython/issues/130843#issuecomment...

pauloxnet•2mo ago
Thanks for pointing this out and for sharing the link.

Mathscapes – Jan 2026 [pdf]

https://momath.org/wp-content/uploads/2026/02/1.-Mathscapes-January-2026-with-Solution.pdf
1•vismit2000•1m ago•0 comments

80386 Barrel Shifter

https://nand2mario.github.io/posts/2026/80386_barrel_shifter/
1•jamesbowman•1m ago•0 comments

Training Foundation Models Directly on Human Brain Data

https://arxiv.org/abs/2601.12053
1•helloplanets•2m ago•0 comments

Web Speech API on HN Threads

https://toulas.ch/projects/hn-readaloud/
1•etoulas•4m ago•0 comments

ArtisanForge: Learn Laravel through a gamified RPG adventure – 100% free

https://artisanforge.online/
1•grazulex•5m ago•1 comments

Your phone edits all your photos with AI – is it changing your view of reality?

https://www.bbc.com/future/article/20260203-the-ai-that-quietly-edits-all-of-your-photos
1•breve•6m ago•0 comments

DStack, a small Bash tool for managing Docker Compose projects

https://github.com/KyanJeuring/dstack
1•kppjeuring•7m ago•1 comments

Hop – Fast SSH connection manager with TUI dashboard

https://github.com/danmartuszewski/hop
1•danmartuszewski•7m ago•1 comments

Turning books to courses using AI

https://www.book2course.org/
1•syukursyakir•9m ago•0 comments

Top #1 AI Video Agent: Free All in One AI Video and Image Agent by Vidzoo AI

https://vidzoo.ai
1•Evan233•9m ago•1 comments

Ask HN: How would you design an LLM-unfriendly language?

1•sph•11m ago•0 comments

Show HN: MuxPod – A mobile tmux client for monitoring AI agents on the go

https://github.com/moezakura/mux-pod
1•moezakura•11m ago•0 comments

March for Billionaires

https://marchforbillionaires.org/
1•gscott•11m ago•0 comments

Turn Claude Code/OpenClaw into Your Local Lovart – AI Design MCP Server

https://github.com/jau123/MeiGen-Art
1•jaujaujau•12m ago•0 comments

An Nginx Engineer Took over AI's Benchmark Tool

https://github.com/hongzhidao/jsbench/tree/main/docs
1•zhidao9•14m ago•0 comments

Use fn-keys as fn-keys for chosen apps in OS X

https://www.balanci.ng/tools/karabiner-function-key-generator.html
1•thelollies•15m ago•1 comments

Sir/SIEN: A communication protocol for production outages

https://getsimul.com/blog/communicate-outage-to-ceo
1•pingananth•16m ago•1 comments

Show HN: OpenCode for Meetings

https://getscripta.app
1•whitemyrat•17m ago•1 comments

The chaos in the US is affecting open source software and its developers

https://www.osnews.com/story/144348/the-chaos-in-the-us-is-affecting-open-source-software-and-its...
1•pjmlp•18m ago•0 comments

The world heard JD Vance being booed at the Olympics. Except for viewers in USA

https://www.theguardian.com/sport/2026/feb/07/jd-vance-boos-winter-olympics
59•treetalker•20m ago•12 comments

The original vi is a product of its time (and its time has passed)

https://utcc.utoronto.ca/~cks/space/blog/unix/ViIsAProductOfItsTime
1•ingve•27m ago•0 comments

Circumstantial Complexity, LLMs and Large Scale Architecture

https://www.datagubbe.se/aiarch/
1•ingve•34m ago•0 comments

Tech Bro Saga: big tech critique essay series

1•dikobraz•37m ago•0 comments

Show HN: A calculus course with an AI tutor watching the lectures with you

https://calculus.academa.ai/
1•apoogdk•41m ago•0 comments

Show HN: 83K lines of C++ – cryptocurrency written from scratch, not a fork

https://github.com/Kristian5013/flow-protocol
1•kristianXXI•46m ago•0 comments

Show HN: SAA – A minimal shell-as-chat agent using only Bash

https://github.com/moravy-mochi/saa
1•mrvmochi•46m ago•0 comments

Mario Tchou

https://en.wikipedia.org/wiki/Mario_Tchou
1•simonebrunozzi•47m ago•0 comments

Does Anyone Even Know What's Happening in Zim?

https://mayberay.bearblog.dev/does-anyone-even-know-whats-happening-in-zim-right-now/
1•mugamuga•48m ago•0 comments

The last Morse code maritime radio station in North America [video]

https://www.youtube.com/watch?v=GzN-D0yIkGQ
1•austinallegro•50m ago•0 comments

Show HN: Hacker Newspaper – Yet another HN front end optimized for mobile

https://hackernews.paperd.ink/
2•robertlangdon•51m ago•0 comments