我正在尝试为Django项目运行服务器,它向我显示此错误: 包含的URLconf'Smartfarmer.urls'似乎没有任何模式。如果您在文件中看到有效的模式,则说明问题可能是由循环导入引起的。
即使同一项目在另一个环境中也可以正常工作
我试图检查网址中是否有任何错误,但我相信一切都很好
我的项目的urls文件: smartfarmer.urls:
from django.conf.urls import include, url
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static
from main_app import views
urlpatterns = [
url(r'^admin/',admin.site.urls),
url(r'^',
include('main_app.urls')),
url(r'^detect/',
include('detect.urls')),
]
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)
我的应用程序网址:
main_app.urls:
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.index),
]
detect.urls:
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^result/$', views.result, name='result'),
]
答案 0 :(得分:0)
smartfarmer.urls:
from django.conf.urls import include, url
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^', include('main_app.urls', namespace="main")),
url(r'^detect/', include('detect.urls', namespace="detect")),
]
main_app.urls:
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.index, name="index"),
]
main_app.urls:
from django.conf.urls import url
from . import views
app_name = "main"
urlpatterns = [
url(r'^$', views.index, name="index"),
]
detect.urls:
from django.conf.urls import url
from . import views
app_name = "detect"
urlpatterns = [
url(r'^result/$', views.result, name='result'),
]