Django 4.2 has been released with a host of new features and fixes, including support for Psycopg3, a new way to create users with a ModelForm of the User model, and a new option to merge model changes into the latest migration.
Here’s an overview of the most notable changes in Django 4.2:
New Features:
- Psycopg3 is now supported.
- It is now possible to add comments to database tables and columns, useful for people without access to your code.
- You can now specify the role for the database connection with Psycopg3 in the connection options settings.
- The new option “makemigrations –update” merges model changes into the latest migration and optimizes the resulting operations.
- Classes RequestFactory, AsyncRequestFactory, Client, and AsyncClient now support the “headers” parameter, allowing a more natural syntax for declaring headers.
- GzipMiddleware includes a fix to mitigate Breach attacks when compressing web page content.
- The new “STORAGE” parameter allows specifying the file system and static files in the same parameter, while also declaring multiple backends.
- Django administration adds a switch to choose the color theme: dark, light, or system-based.
- The number of iterations for the PBKDF2 hash has been increased from 390,000 to 600,000.
- CommonPasswordValidator updated with new common passwords.
- ManifestStaticFilesStorage supports replacing imports and exports with hashed counterparts (experimental).
- New asynchronous versions of database manipulation methods added: adelete(), arefresh_from_db(), and asave().
Changes and Improvements:
- The new way to create a user with a ModelForm of the User model is to use BaseUserCreationForm. Now, the username is case-sensitive (previously “Gaetan” and “gaetan” were allowed).
- It is recommended to use the “secrets” library to generate random passwords instead of BaseUserManager.make_random_password() method.
- Session cookies are now automatically replaced by stars in error reports.
- The HTML debug page has improved error handling and requires Python 3.11.
- The Django logging system now logs database transactions of types BEGIN, ROLLBACK, and COMMIT at the DEBUG level.
For the complete list of changes, you can refer to the Django 4.2 Release Notes.
I hope this article was helpful, if you have any question or suggestion, feel free to reach out to me on :
- By email at [email protected].
- If you want to know more about me, you can check out my about page.
You can use my articles with no cost or attribution, feel free to edit them and make them your own.