Keeping up with every single release of your tech stack is exhausting and mostly a waste of time. Let us skip the marketing fluff and look at the concrete changes in Python, Django, and PostgreSQL that actually improve your daily workflow.
- How to use Python's new type-hinting shortcuts for cleaner code
- Simplifying Django database queries with new conditional operators
- Leveraging PostgreSQL JSON path filtering for faster lookups
Cleaner Type Hints in Python
Python makes it easier to write type hints—which are notes in your code that explain what kind of data a function expects. You no longer need to import special helper tools just to define optional values or lists.
Here is how you wrote a function that accepts a string or nothing in older Python versions:
from typing import Optional, List
def get_user_names(user_id: int) -> Optional[List[str]]:
passHere is the cleaner way to write the exact same code today:
def get_user_names(user_id: int) -> list[str] | None:
passThe key takeaway is that your code is now shorter and uses built-in types instead of imports.
Simpler Database Filtering in Django
Django makes it easier to filter your database records directly using native database functions without writing raw SQL. This helps you keep your business logic inside your Python models.
Here is how you might filter query results based on a related count before:
from django.db.models import Count
active_users = User.objects.annotate(post_count=Count('posts')).filter(post_count__gt=5)The takeaway is that cleaner query methods let you express complex database conditions with fewer lines of code.
Things to watch out for
New features are exciting, but upgrading your tools can occasionally break existing code if you are not careful. Always check your third-party packages before upgrading Python or Django versions in production. Database migrations in PostgreSQL can also lock tables if you run heavy queries on massive datasets during peak traffic hours.
Pick just one of these features to try out in your current project today.