Repository: jazzband/django-debug-toolbar

Issue:
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.
After django-debug-toolbar installation:

```
/usr/src/app/byvshie/urls.py:25: 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'^__debug__/', include(debug_toolbar.urls)),
```



Discussion:
Are you running the latest version of the debug toolbar?

django-debug-toolbar==1.5

You ask because of you do not see this warning?..

I use latest Django 1.10.1 and run /usr/local/bin/python3  -u -Wall /usr/src/app/manage.py check

Hmm — I was confused, sorry. Now I see why this happens.

Hmm — I was confused, sorry. Now I see why this happens.

I'm not sure which version introduced this warning, and whether the toolbar still supports earlier versions. If it does we need to wait a bit to make this change.

Since 1.9
https://docs.djangoproject.com/en/dev/releases/1.9/#passing-a-3-tuple-or-an-app-name-to-include

It's too early to change this, since we're still supporting Django 1.8 at this time.

Since it's only annoying and not actively harmful I'm not too interested personally to change this. (It IS annoying that debug-toolbar is the only library in most projects still spewing warnings, but oh well.)

> since we're still supporting Django 1.8 at this time.

I feel we should somehow fix this without dropping 1.8 support because of end of extended support for 1.8 is "Until at least April 2018" and release date for Django 2.0 is "December 2017  "

![](https://www.djangoproject.com/s/img/release-roadmap.e844db08610e.png)

(Image From https://www.djangoproject.com/download/ )

Yes, if there is a good and nice way to fix this. Pull requests are always welcome!

If it was just a matter of:

``` python
if django.VERSION < (1, 9):
    urls = ...
else:
    urls = ...
```

it would be simple.

But I think we'll need to change the installation instructions for 1.8+.

I'm not going to work on this, feel free to go ahead and submit a PR.

According to the release notes, the namespace and app_name in the tuple can both be replaced by "passing an object or module with an app_name attribute" - so this line in `__init__.py`

```
urls = 'debug_toolbar.toolbar', 'djdt', 'djdt'
```

could be replaced with 

```
if django.VERSION < (1, 9):
    urls = 'debug_toolbar.toolbar', 'djdt', 'djdt'
else:
    from . import toolbar
    toolbar.app_name = 'djdt'
    urls = toolbar
```

If the devs are happy with this I'll go ahead and make a PR.

Sounds good. Please go ahead.


Resolving patch:
diff --git a/debug_toolbar/__init__.py b/debug_toolbar/__init__.py
--- a/debug_toolbar/__init__.py
+++ b/debug_toolbar/__init__.py
@@ -1,5 +1,7 @@
 from __future__ import absolute_import, unicode_literals
 
+import django
+
 __all__ = ['VERSION']
 
 
@@ -11,9 +13,14 @@
 
 
 # Code that discovers files or modules in INSTALLED_APPS imports this module.
-# Reference URLpatterns with a string to avoid the risk of circular imports.
-
-urls = 'debug_toolbar.toolbar', 'djdt', 'djdt'
-
+# URLpatterns were referenced with a string prior to 1.9 to avoid the risk of
+# circular imports
+
+if django.VERSION < (1, 9):
+    urls = 'debug_toolbar.toolbar', 'djdt', 'djdt'
+else:
+    from . import toolbar
+    toolbar.app_name = 'djdt'
+    urls = toolbar
 
 default_app_config = 'debug_toolbar.apps.DebugToolbarConfig'


Test patch: