### 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.
### Postgres upgrade
If you're using `postgres` for your database and you're using `< 14`, you'll need to update. This is one reason I _love_ Docker. If you're using Docker and Docker compose, open `docker-compose.yml` and update the database service to at least postgres 16 (but I prefer 17 at the time of this writing).
```yml
# docker-compose.yml
services:
...
postgres:
image: postgres:17
...
```
### 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.
### Package versions that work
Here are some common Python packages that work with Django 5.2 and Wagtail 6.4:
```
django-adminactions==2.3.0
django-extensions==3.2.3
django-widget-tweaks==1.5.0
django-el-pagination==4.1.2
django-allauth==65.7.0
wagtail-generic-chooser==0.6.1
django-countries==7.6.1
django-phone-field==1.8.1
```
### Applying Migrations and Final Steps
To complete your upgrade, apply the necessary Wagtail migrations and update your search index:
```
python manage.py migrate
python manage.py update_index
```
After migration, running your project should show the updated Wagtail in action, with fewer legacy features and a cleaner, more streamlined setup. And running the `python manage.py update_index` command will make sure your Wagtail admin-based search works as expected.
Kalob Taulien
Wagtail CMS enthusiast; Wagtail core team member; Coding teacher.