配置不正确创建新的 Django 应用程序时出错



我在创建新应用程序(模拟器管理(时遇到此错误:

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

以下是相关文件:

urls.py

from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.emulatorsMgmt.as_view(),name='emulatorsMgmt'),
]

views.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 存在于模板/模拟器管理文件夹中。此外,我在中央项目的 urls.py 中进行了以下添加:

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

我还在我的 setting.py 目录中添加了该应用程序。 我想知道我哪里出错了。任何帮助将不胜感激!

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

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

最新更新