I am working on a GSoC proposal for Wagtail CMS. As part of my preparation, I set up a multilingual demo site using wagtail-localize. I learned a lot about how Wagtail handles translations and found a bug along the way.
What I Was Doing
I extended Wagtail's Bakery Demo with three languages: English, Spanish, and French. For Spanish, I translated pages one by one. For French, I used the "Include subtree" option to translate an entire section at once.
The Spanish pages worked fine, but the French pages had a strange problem.
What Went Wrong
After translating the French subtree, I could not see any child pages in the admin panel. The pages existed in the database. They had content. But the admin explorer showed nothing under the French homepage.
I got "Page not found" errors when I visited the child page URLs directly, even though the pages exist.
How I Diagnosed It
I wrote a small script to check the page tree data. Every Wagtail page stores a field called numchild. This tells the admin how many children a page has. If numchild is zero, the admin skips the database query to find children.
The French homepage had numchild = 0, even though it had several child pages. The "Include subtree" translation made the child pages but didn't update the parent's counter.
This happens because wagtail-localize uses django-treebeard to manage the page tree. When it makes many pages at once during subtree translation, it skips updating numchild.
How I Fixed It
The fix was simple. I ran one command in the Django shell:
from wagtail.models import Page
Page.fix_tree()
This rebuilt the tree metadata. All French child pages showed up in the admin and loaded fine on the frontend.
What I Learned
Translation tools can have subtle data bugs. The pages were created correctly, but the metadata was wrong. This kind of bug is hard to spot because everything looks fine until you check the admin explorer.
numchildis critical for Wagtail's page tree. It controls whether the admin even tries to find child pages. A wrong value makes pages invisible.Bulk operations need extra care. When you create many pages at once, update all related metadata too. It's not enough to just update the pages.
I reported this as issue #773 in wagtail-localize. The bug is still open and needs a permanent fix in the package.
If you use wagtail-localize's subtree translation feature, watch out for this. Running Page.fix_tree() is a good workaround until the fix is merged.
Check out my multilingual demo: sushanthaaa.pythonanywhere.com | Source code


Top comments (0)