🚀 Feature Friday: Database-computed default values in Django!
Did you know about db_default field attribute that recently landed in Django 5.0 ?
This feature allows the database to calculate the default values of your model fields. 🧵 (1/3)
🚀 Feature Friday: Database-computed default values in Django!
Did you know about db_default field attribute that recently landed in Django 5.0 ?
This feature allows the database to calculate the default values of your model fields. 🧵 (1/3)
🚀 Feature Friday: Simplified templates for form field rendering !
Django 5.0 introduced a field group and field group templates, simplifying the rendering of related form field elements like labels, widgets, help text, and errors.
🧵 (1/2)
🚀 Feature Friday: This new testing feature is available for Python 3.12+ users with Django 5.0+ ⏰
With "test --durations", you can quickly find the slowest tests in your project, letting you optimize things where they'll have the most impact.
🚀 Feature Friday: Unique constraints with null values!
Have you ever had a Model field that you wanted to be optional, but unique if it was present?
Django 5.0's new nulls_distinct attribute now allows you to do this!
🧵 (1/3)
#Django #DjangoFeatureFriday
🎉 Feature Friday: Django's Database-Generated Fields!
Need DB-generated values in your Django models? Meet the new GeneratedField!
Define fields with values created by the database, not Django. Powerful for computed columns & more.
DB-generated fields can be used for the following use cases:
• Computed columns
• Default values from DB functions
• Auto-updating timestamps
🧵 (1/2)
#Django #DjangoFeatureFriday
Here's a small sample code showing the usage of GeneratedField:
🚀 Feature Friday: QuerySet.prefetch_related() supports GenericForeignKey for Django 5.0 and above!
This seemingly minor change might be a big win for performance in your django projects. Let’s see how 👇
#Django #DjangoFeatureFriday
🧵 (1/3)
🚀 Feature Friday: Django 4.2 introduced a major feature, Comments on columns and tables. This powerful addition enhances database schema documentation right in your models. 🗂️💬
#Django #DjangoFeatureFriday
🧵 (1/3)
🚀 Feature Friday: Did you know about facet counts in django admin?
Facet counts are now visible for applied filters in the admin panel. It can be toggled on/off using show_facets attribute, giving you more control over your data visualization.
#DjangoFeatureFriday
🧵 (1/2)
🚀 Feature Friday: Django's update_or_create() got Smarter in v5.0!
The new create_defaults argument lets you handle creation vs update scenarios elegantly, bringing more power to Django's object management.
🧵 (1/3)
#Django #DjangoFeatureFriday
🚀 Feature Friday: Django 5.0 introduced more options for declaring field choices!
Now you can use Mapping, a callable, and strings for single-character choices, in addition to the traditional tuples and enumeration.
🧵 (1/3)
#Django #DjangoFeatureFriday
🚀 Feature Friday: PostgreSQL Connection Pools!
This small-but-mighty change lets you enable connection pooling with a single line in your settings. This reduces the overhead of accessing your database, leading to improved performance.
🧵 (1/3)
#Django #DjangoFeatureFriday
🚀 Feature Friday: LoginRequiredMiddleware!
The LoginRequiredMiddleware is great for any Django app that is mostly behind authentication. When enabled, views will require login by default. No more login_required decorators everywhere!
🧵 (1/3)
#Django #DjangoFeatureFriday
🚀 Feature Friday: assertNumQueries!
This method from TransactionTestCase helps you write tests that verify the number of queries made by a piece of code.
It is a great way to check DB performance and catch regressions or "n+1" issues.
🧵 (1/3)
🚀 Feature Friday: Context Processors!
If you use Django, you've likely relied on context processors before—features like auth, i18n, static files and messages all use them.
Let's learn about this simple-but-useful tool to add extra context to your Django views.
🧵 1/4
#DjangoFeatureFriday
🚀 Feature Friday: {% querystring %} !
The new {% querystring %} template tag in Django 5.1 makes it easier to access and modify the query string in your Django templates, letting you work with links that use query parameters.
🧵 (1/3)
#Django #DjangoFeatureFriday
Feature Friday is going on a seasonal break! We'll be back in 2025. In the meantime, if there are Django features you'd like to see covered leave a reply below ⬇️