django - 创建新的 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 目录中添加了该应用程序。我想知道我哪里出错了。任何帮助是极大的赞赏!
解决方案
您在根 urlconf 中错误地包含了应用程序 url。我认为应该是:
url(r'^emulatorsMgmt/', include('apps.emulatorsMgmt.urls'))
推荐阅读
- python - closeTab 函数它在 PyQt5 中关闭多个选项卡
- python-3.x - 如何取消点的重叠,并以相同的坐标展开点(像一个小簇)?
- swift - 使用 URLSessionDataTask 和 @Published 的内存泄漏
- python - 限制用户使用软件的时间
- xamarin.android - Cannot find PairingParams.PAIRING_VARIANT_CONSENT in Xamarin.Android
- javascript - Reduce throws "NaN" in JavaScript?
- python - Problem in downloading image through urllib.request
- python - Python Click Option Backspace
- r - 按年循环 lm
- node.js - 使用前缀 discord.js 的名称