You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为何Wagtail关键字会追加到新建应用名称后导致Django报错?

Hey there! Let's sort out this frustrating issue you're facing while setting up your first Wagtail blog app.

问题根源

That error No module named 'blog.apps.BlogConfigwagtail' tells us exactly what's wrong: in your project's settings.py, you accidentally merged your blog app's configuration with a Wagtail-related entry into a single invalid string. Instead of keeping them as separate list items in INSTALLED_APPS, you ended up with something like 'blog.apps.BlogConfigwagtail' — which Django can't recognize because that module doesn't exist.

解决步骤

Follow these simple fixes:

  1. Open your project's settings.py file (usually in the root project folder, alongside manage.py).
  2. Scroll down to the INSTALLED_APPS list.
  3. Look for any line that combines your blog app config with "wagtail" — it'll look something like this (wrong):
    # ❌ Wrong entry
    'blog.apps.BlogConfigwagtail',
    
  4. Split this into two separate, correct entries. Your blog app config and Wagtail's apps should each be their own item in the list. Here's how it should look:
    INSTALLED_APPS = [
        # ... keep your existing core Django apps here (like 'django.contrib.admin', etc.)
        
        # Your custom blog app
        'blog.apps.BlogConfig',
        
        # Wagtail's required apps (add these if you haven't already)
        'wagtail.contrib.forms',
        'wagtail.contrib.redirects',
        'wagtail.embeds',
        'wagtail.sites',
        'wagtail.users',
        'wagtail.snippets',
        'wagtail.documents',
        'wagtail.images',
        'wagtail.search',
        'wagtail.admin',
        'wagtail',
        
        # ... other dependencies like 'modelcluster', 'taggit' go here too
    ]
    
  5. Save the settings.py file.
  6. Run python manage.py makemigrations again — it should work without that error now!

Quick Explanation

Django checks each entry in INSTALLED_APPS to load the corresponding app module. When you mashed your blog's BlogConfig with "wagtail", it tried to find a non-existent module called BlogConfigwagtail inside blog.apps, which obviously doesn't exist. Splitting them into separate entries lets Django find both your custom blog app and Wagtail's apps correctly.

内容的提问来源于stack exchange,提问作者rahim asgari

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 09:02:38