---
canonical: "https://www.jsolly.com/blog/migrating-to-django-4x/"
title: "Upgrading to Django 4.0: Navigating Dependency and Migration Errors"
description: "Navigating dependency and migration errors while upgrading to Django 4.0 - A guide to upgrading from Django 3.2.14 to 4.0.5"
author: "John Solly"
published: "2022-06-09T02:34:50.000Z"
updated: "2026-09-07T14:25:05.480Z"
---

<a id="upgrading-to-django-40-navigating-dependency-and-migration-errors"></a>

# Upgrading to Django 4.0: Navigating Dependency and Migration Errors

![Django support timeline. Shows 3.2 support ending in 2022.](https://d1d7p8ufhgz4ld.cloudfront.net/media/post_metaimgs/django_support_timeline.jpg)

My friend Justin created an issue in my repo for migrating to Django 4.0. I couldn’t because a dependency, [django-admin-honeypot](https://github.com/dmpayton/django-admin-honeypot), and [HTMX](https://django-htmx.readthedocs.io/en/latest/installation.html) did not work on 4.0. I made the leap after HTMX officially started advertising 4.0 support.

With [this PR](https://github.com/jsolly/blogthedata/pull/105/commits/51116b5017ecd6b13dc505be0fcb9a92cbab759f), I’ve migrated blogthedata.com to Django 4.0.5.

<a id="the-upgrade"></a>

## **The upgrade**

<a id="startup-error"></a>

### **Startup Error**

I followed my [upgrade document](https://www.jsolly.com/blog/upgrading-to-the-latest-3x-django/) and ran into my first issue; The app wouldn’t start! There was an error in the console:

<pre><code class="language-python"> RuntimeError: populate() isn’t reentrant</code></pre>

It’s an unhelpful Django error often due to a misconfigured dependency in settings.py. Someone mentioned in [this SO thread](https://stackoverflow.com/questions/27093746/django-stops-working-with-runtimeerror-populate-isnt-reentrant/55929118#55929118) that a one-line change in `django/apps/`[`registry.py`](https://app.prowritingaid.com/registry.py) surfaces the error.

Sure enough, the error was coming from a module [I incorporated in the past](https://www.jsolly.com/blog/admin-honeypot-page-to-catch-hackers/).

<pre><code class="language-python"> Could not import ugettext_lazy</code></pre>

The [Django 4.0 upgrade doc](https://docs.djangoproject.com/en/4.0/releases/4.0/) states that Django 4.0 removes this import.

I found an [open issue](https://github.com/dmpayton/django-admin-honeypot/issues/87) in the django-admin-honeypot repo, but no one has actioned it for three months. My options were:

1 - Drop the package

2 - Patch it myself

3 - Find a replacement.

There are similar repos ([1](https://github.com/jamesturk/django-honeypot/), [2](https://github.com/blag/django-admin-honeypot)), but these packages aren’t well maintained either. Additionally, re-work was required to change modules. I chose to eliminate the dependency. Although the functionality is interesting, it hasn’t caught any login attempts (who hacks a personal blog?). 

<a id="migration-error"></a>

### **Migration error**

The app failed again but from a migration error. Migration, 0006\_change\_content\_field\_to\_richtextuploading.py, imports the old django-ckeditor package I used when first implementing CKEditor.

I saw [this ticket](https://code.djangoproject.com/ticket/25327) in the official Django repo, where a commenter suggests [migration squashing](https://docs.djangoproject.com/en/dev/topics/migrations/#migration-squashing). Squash migrations reduce the number of migrations by ‘squashing’ them into one file.

<pre><code class="language-python">$ python3 manage.py squashmigrations blog 0006                                             
Will squash the following migrations:
 - 0001_initial
 - 0002_add_likes
 - 0003_add_views_to_Post
 - 0004_add_slug_field
 - 0005_add_images_to_post
 - 0006_change_content_field_to_richtextuploading
Do you wish to proceed? [yN] </code></pre>

Typed ‘Y’ and hit enter

<pre><code class="language-python">Created new squashed migration /Users/johnsolly/Documents/code/blogthedata/django_project/blog/migrations/0001_squashed_0006_change_content_field_to_richtextuploading.py
  You should commit this migration but leave the old ones in place;
  the new migration will be used for new installs. Once you are sure
  all instances of the codebase have applied the migrations you squashed,
  you can delete them.</code></pre>

I followed the instructions, and everything started working again! 

<a id="conclusion"></a>

## **Conclusion**

I ran into two errors during the upgrade from Django 3.2.14 to 4.0.5. The first was a third-party dependency not supported on 4.0. A second issue was a migration error from a removed dependency. The missing import was resolved by eliminating a dependency. The second issue was addressed by squashing migrations.

I am excited to now use Django 4.0!

June 9, 2022 in [Web Dev](https://www.jsolly.com/blog/category/web-dev/)

Updated September 7, 2026
