### Transitioning to Wagtail 6.0: Fully Embracing Django 5.0 and Python 3.12
The upgrade to Wagtail 6.0 is a significant leap forward, aligning your project with the latest developments in web technology. With this update, we officially move to Django 5.0 and, optionally, Python 3.12.
### Preparing for Upgrade
Before diving into the upgrade process, it's crucial to understand what Wagtail 6.0 entails by checking the [release notes](https://docs.wagtail.org/en/stable/releases/6.0.html). Notably, Django 5.0 is now supported, which also requires a Python update to ensure compatibility.
### Updating Your Docker Environment
With the transition to Python 3.12, your Dockerfile will need an update:
```Dockerfile
FROM python:3.12
```
For those utilizing `psycopg2-binary` in conjunction with Python 3.12, make sure to upgrade to `psycopg2-binary==2.9.9` to avoid build issues during installation.
### Setting Up Requirements.txt
Update your `requirements.txt` to include the latest versions of Django and Wagtail available at the time of writing:
```
Django==5.0.4
wagtail==6.0.2
```
### Transitioning from `django-adminactions`
If you're using `django-adminactions`, consider upgrading to `django-adminactions==2.3.0`. Alternatively, it's advisable to switch to Wagtail’s new ModelViewSets, which offer built-in export options, making third-party packages unnecessary for this functionality.
### Key Changes in Wagtail 6.0
Wagtail 6.0 has removed the ModelAdmin app. It's now preferred that developers use `ModelViewSet`. If you haven’t yet transitioned from ModelAdmin (covered in the upgrade to Wagtail 5.x), now is the time. The functionality previously provided by Wagtail's contrib package, ModelAdmin, is now available via a third-party package, `wagtail-modeladmin`.
### Handling Recaptcha Updates
For those utilizing reCAPTCHA:
```python
# Update your imports for ReCaptchaField
from django_recaptcha.fields import ReCaptchaField
# And update your INSTALLED_APPS
INSTALLED_APPS = [
...
'django_recaptcha',
...
]
```
### Updating Wagtail’s Built-in Search
If your site uses Wagtail's built-in search functionality, update your code to reflect the new location of the `Query` model:
1. Add `wagtail.contrib.search_promotions` to your `INSTALLED_APPS` in `base.py`.
2. Change import statements in `search/views.py`:
```python
from wagtail.contrib.search_promotions.models import Query
```
### StreamField Update
With Wagtail 6.0, `use_json_field=True` in StreamFields is no longer required. If you have specified this in your StreamFields, you can safely remove it.
### Applying Migrations and Final Steps
To complete your upgrade, apply the necessary Wagtail migrations:
```
python manage.py migrate
```
After migration, running your project should show the updated Wagtail in action, with fewer legacy features and a cleaner, more streamlined setup.
Kalob Taulien
Wagtail CMS enthusiast; Wagtail core team member; Coding teacher.