The Wire · Showcase
DJANGO STRIPS HARDCODED PRIMARY KEYS AHEAD OF NON-INTEGER ID SUPPORT
By RepoJournal · Filed · About Django
Django is systematically removing assumptions that primary keys must be integers, clearing the path for databases like MongoDB that use object IDs.
The framework removed hardcoded Site primary keys across the codebase [1], including a critical fix to runtests.py that now dynamically sets SITE_ID based on the database backend [2]. For MongoDB testing, this switches from hardcoded integer 1 to ObjectId('000000000000000000000001'), unblocking real-world usage of non-integer primary keys. The team also purged integer pk assumptions from AdminCustomQuerysetTest [3], with the same treatment applied elsewhere [4]. This isn't just cleanup. These changes signal Django is preparing for a world where UUIDs, ObjectIds, and other non-integer identifiers are first-class citizens, not edge cases. The deprecation roadmap is being updated to reflect this shift [5], giving extension developers and application authors clear guidance on what's coming. Benchmark infrastructure continues to mature across platforms [6], ensuring performance regressions get caught early.
Action items
- → Review custom code that assumes integer primary keys, especially in Site fixtures and admin querysets django/django [plan]
- → Check deprecation notes when upgrading to the next Django release for primary key handling changes django/django [monitor]
References
- [1] Removed hardcoded Site pks. django/django
- [2] Removed hardcoded Site pks. ↗ django/django
- [3] Removed integer pk assumption in AdminCustomQuerysetTest. django/django
- [4] Removed integer pk assumption in AdminCustomQuerysetTest. ↗ django/django
- [5] Added advancing deprecations to preparing for next release instructions. django/django
- [6] Results for ubuntu-latest added [skip ci] django/django-asv
FAQ
- What changed in Django on May 25, 2026?
- Django is systematically removing assumptions that primary keys must be integers, clearing the path for databases like MongoDB that use object IDs.
- What should Django teams do about it?
- Review custom code that assumes integer primary keys, especially in Site fixtures and admin querysets • Check deprecation notes when upgrading to the next Django release for primary key handling changes
- Which Django repositories shipped on May 25, 2026?
- django/django, django/django-asv