Wagtail项目执行makemigrations报NodeNotFoundError问题求助
NodeNotFoundError for Wagtail Migration Dependency Got it, let's break down how to fix this migration error you're hitting. Here's what's going on: your custom migration named collection-name is referencing an old Wagtail core migration (wagtailcore.0029_unicode_slugfield_dj19) that no longer exists in your current Wagtail version. When you try removing that dependency, other Wagtail-related migrations (like wagtailimages) break because they rely on proper Wagtail core migration state.
Let's fix this step by step:
1. Confirm your current Wagtail version
First, check which version of Wagtail you're running—this old migration was part of much older Wagtail releases (think 1.x or early 2.x):
python3 manage.py wagtail --version
2. Inspect your problematic migration file
Locate the collection-name migration file in your app's migrations folder (e.g., your_app/migrations/XXXX_collection-name.py). Open it and look for the dependencies section—it should have a line like:
dependencies = [ ('wagtailcore', '0029_unicode_slugfield_dj19'), # Other dependencies... ]
3. Update the Wagtail core dependency to a valid migration
You need to replace that outdated wagtailcore migration reference with the latest applied wagtailcore migration in your project:
- Run this command to see all wagtailcore migrations and their status:
python3 manage.py showmigrations wagtailcore - Look for the last migration marked as
[X](already applied). For example, if your latest applied migration is0070_purge_revisions, update the dependency line to:('wagtailcore', '0070_purge_revisions'),
4. Fix other Wagtail-related dependencies (like wagtailimages)
If you're getting errors with wagtailimages or other Wagtail apps, repeat the same process for those:
- Run
python3 manage.py showmigrations wagtailimagesto find the latest applied migration for that app. - Update any outdated references in your
collection-namemigration'sdependenciesto match the valid, applied migration numbers.
5. Verify and re-run migrations
Once you've updated all dependencies:
- First, check for any remaining issues with:
python3 manage.py makemigrations --check - If no errors are reported, run your migrations normally:
python3 manage.py makemigrations python3 manage.py migrate
Bonus: If you're upgrading Wagtail
If this error popped up after a Wagtail version upgrade, double-check you followed the official upgrade steps—some major versions require running specific migration commands or handling schema changes before running your app's migrations.
内容的提问来源于stack exchange,提问作者priyanka priya

