簡體   English   中英

Django 中配置不當的 urls.py

[英]ImproperlyConfigured urls.py in Django

我有以下錯誤,我不知道在我的 urls.py 中更改什么來解決這個問題:

django.core.exceptions.ImproperlyConfigured: The included URLconf 'MLtest.urls' 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.

這是我的 urls.py 的樣子:

from django.contrib import admin
from django.urls import path, include
from MLT import views
import debug_toolbar

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', views.thankYou),
    path(r'^__debug__', include(debug_toolbar.urls)),
]

視圖.py:

from django.shortcuts import render
from django.template import RequestContext
from django.utils.translation import gettext as _

def thankYou(request):
    text = _("this is some random text")
    return render(request, 'thank_you.html', {'text': text})

您不得將正則表達式與 path() 函數一起使用。您的最后一個 url path(r'^__debug__', include(debug_toolbar.urls))包含正則表達式。 您可以在此處查看 url 定義

更正您的網址如下:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM