当我尝试运行服务器时,Django中的错误消息似乎没有任何模式。如果您在

2024-04-26 10:30:39 发布

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

每次我写python manage.py run server。我收到错误消息:

The included URLconf '<module 'strana.views' from 'D:\\novi projekat\\strana\\views.py'>' 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.

mysiteurl.py

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

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

myapp(名为strana)

    from django.urls import path
    from . import views

    urlpatterns = [
        path('', views.index, name='index'),
]

视图.py

    from django.http import HttpResponse


    def index(request):
        return HttpResponse('Kita u Bila')

1条回答
网友
1楼 · 发布于 2024-04-26 10:30:39

您包括了视图模块。您希望包含包含URL的模块

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

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

相关问题 更多 >