gpt4 book ai didi

python - Django 弃用警告或错误配置错误 - 不支持将 3 元组传递给 django.conf.urls.include()

转载 作者:IT老高 更新时间:2023-10-28 21:41:42 26 4
gpt4 key购买 nike

我在 Django 1.11 中有一个弃用警告:

RemovedInDjango20Warning: Passing a 3-tuple to django.conf.urls.include() is deprecated. Pass a 2-tuple containing the list of patterns and app_name, and provide the namespace argument to include() instead.
url(r'^admin/', include(admin.site.urls))

在 Django 2.0 中,这给出了错误:

django.core.exceptions.ImproperlyConfigured: Passing a 3-tuple to include() is not supported. 
Pass a 2-tuple containing the list of patterns and app_name, and provide the namespace argument to include() instead.

我应该如何更改 url(r'^admin/', include(admin.site.urls))?我试图查看文档,但我不知道......

这是我的 urls.py:

from django.conf.urls import include, url
from django.contrib import admin
admin.autodiscover()

urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^admin/django-ses/', include('django_ses.urls')),
url(r'^api/1.0/', include('feedcrunch_api_v1.urls')),
url(r'^oauth/', include('oauth.urls')),
url(r'^@(?P<feedname>\w+)/admin/', include('feedcrunch_rssadmin.urls')),
url(r'^@(?P<feedname>\w+)/', include('feedcrunch_rssviewer.urls')),
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
url(r'', include('feedcrunch_home.urls')),
]

最佳答案

从 Django 1.9 开始,the old way of including the admin urls is deprecated .您应该将 admin.site.urls 直接传递给 url(),而不需要调用 include():

from django.contrib import admin

urlpatterns = [
url(r'^admin/', admin.site.urls),
...
]

关于python - Django 弃用警告或错误配置错误 - 不支持将 3 元组传递给 django.conf.urls.include(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43324005/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com