作者热门文章
- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我在 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/
我是一名优秀的程序员,十分优秀!