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

Django 1.11.1启动报错:Included URLconf does not have any patterns in it

Fixing "Included URLconf does not have any patterns in it" in Django 1.11.1

Hey there, let's get this sorted out quickly! That error is pointing straight to your polls.urls file — Django can't find any valid URL patterns defined there, which is why it's throwing that message when you run python manage.py runserver.

Here's what you need to check and fix:

  • Verify your polls/urls.py has a proper urlpatterns list
    Since you mentioned the file starts with from django...., make sure you've completed the rest of the file to define the required URL routes. For Django 1.11, your polls/urls.py should look something like this (matching the official tutorial structure):

    from django.conf.urls import url
    from . import views
    
    urlpatterns = [
        # Example route for the polls homepage (maps to polls/)
        url(r'^$', views.index, name='index'),
        # Add other routes like detail, vote, results as per the tutorial
        # url(r'^(?P<question_id>[0-9]+)/$', views.detail, name='detail'),
        # url(r'^(?P<question_id>[0-9]+)/vote/$', views.vote, name='vote'),
        # url(r'^(?P<question_id>[0-9]+)/results/$', views.results, name='results'),
    ]
    

    The key here is that urlpatterns must be a non-empty list containing at least one url() entry. If this list is missing, empty, or has syntax errors (like missing commas, incorrect imports), Django will think there are no patterns.

  • Double-check polls is in your INSTALLED_APPS
    While this isn't the direct cause of the URL pattern error, it's a good sanity check to ensure your app is properly registered in settings.py:

    INSTALLED_APPS = [
        'polls',  # Make sure this line exists
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
    ]
    
  • Check for syntax errors in polls/urls.py
    Even a tiny typo (like a missing closing parenthesis or comma) can prevent Python from parsing the file correctly, which would make Django unable to detect the urlpatterns list. Go through the file carefully to fix any syntax issues.

Once you've updated polls/urls.py to include valid patterns, restart your runserver and the error should be gone!

内容的提问来源于stack exchange,提问作者Israel Gboluwaga

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 11:45:16