74

I have a deprecation warning in 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))

In Django 2.0 this gives the error:

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.

How should I change url(r'^admin/', include(admin.site.urls))? I tried to look at the documentation, but I have no clue ...

Here is my 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')),
]
1
  • 3
    As an aside, you can remove admin.autodiscover() -- it has not been required since Django 1.7.
    – Alasdair
    Apr 10, 2017 at 13:29

3 Answers 3

145

As of Django 1.9, the old way of including the admin urls is deprecated. You should pass admin.site.urls directly to url(), without the call to include():

from django.contrib import admin

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

I struggled with this on my Macbook. I had a virtual environment activated with Django 2.0 installed. But django-admin was still pointing to a system level install from an old version of django. My solution was to uninstall the system level django. After that, django-admin was pointing to the newer virtualenv version.

0

It's problem belongs to your global virtualenv.First step deactivate your virtualenv and delete your old django module.

1.Deactivate your virtualenv deactivate

2.Delete your old django module pip uninstall django

3.Activate yor virtualenv and install new django module

Happy Coding 🎉

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.