Django.core.exceptions.ImpropertlyConfigured:即将发生错误

2024-04-29 04:01:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我对Django是新来的,因此对它不太了解。我正在尝试创建一个应用程序,该应用程序在my view.py文件中包含以下内容:

from django.shortcuts import render
from fusioncharts.models import City

def pie_chart(request):
    labels = []
    data = []

    queryset = City.objects.order_by('-population')[:3]
    for city in queryset:
        labels.append(city.name)
        data.append(city.population)

    return render(request, 'pie_chart.html', {
        'labels': labels,
        'data': data,
    })

应用程序中my urls.py文件的内容如下:

from django.urls import path
from fusioncharts import views

urlpatterns = [
    path('pie-chart/', views.pie_chart, name='pie-chart'),
]

主项目文件夹中my urls.py文件的内容如下:

from django.contrib import admin
from django.urls import path

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('fusioncharts.urls'))
]

在settings.py文件中,我添加了以下内容:

ROOT_URLCONF = 'Piechart.urls'

并在模板下添加以下内容:

'DIRS': ['Piechart/fusioncharts/templates'], 

现在,在运行我的应用程序时,我遇到以下错误:

django.core.exceptions.ImproperlyConfigured: The included URLconf 'Piechart.urls' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.

谁能告诉我出了什么问题吗


Tags: 文件pathdjangofrompyimport应用程序city