首页 > 解决方案 > 创建新的 Django 应用程序时配置错误

问题描述

我在创建新应用程序(emulatorsMgmt)时遇到了这个确切的错误:

' ./apps/emulatorsMgmt/init .py'>' 中包含的 urlconf '<module 'apps.emulatorsMgmt'似乎没有任何模式。如果您在文件中看到有效模式,则问题可能是由循环导入引起的。

以下是相关文件:

网址.py

from django.conf.urls import url
from . import views

urlpatterns = [
    url(r'^$', views.emulatorsMgmt.as_view(),name='emulatorsMgmt'),
]

视图.py:

from django.shortcuts import render
from django.views.generic import View

# Create your views here.
class emulatorsMgmt(View):
    def get(self, request):
        return render(request, 'hello.html')

hello.html 存在于 templates/emulatorsMgmt 文件夹中。我还在中心项目的 urls.py 中添加了以下内容:

url(r'^emulatorsMgmt/', include('apps.emulatorsMgmt'))

我还在我的setting.py 目录中添加了该应用程序。我想知道我哪里出错了。任何帮助是极大的赞赏!

标签: django

解决方案


您在根 urlconf 中错误地包含了应用程序 url。我认为应该是:

url(r'^emulatorsMgmt/', include('apps.emulatorsMgmt.urls'))

推荐阅读