﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
25035	urlresolvers.reverse doesn't resolve a namespaced URL when passed a callable	Adam Brenecki	nobody	"When I pass a view callable to `django.core.urlresolvers.reverse`, it resolves correctly if the callable is in the top-level `urlpatterns`, or one in a `urlpatterns` that's been `include`d without a namespace, but not one that's been `include`d with a namespace.

I've noticed this behaviour in 1.7 and in the current HEAD of master (as of 736fb1838cc25f5faf57cd2a4f6b6ab32ff9aadc).

Here's a minimal example (all files not listed are as generated by `startproject`/`startapp`):

`testproj/urls.py`
{{{#!python
from django.conf.urls import url, include
from django.contrib import admin
import testapp.urls

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^testapp/', include(testapp.urls, namespace='testapp')),
]
}}}

`testapp/urls.py`
{{{#!python
from django.conf.urls import url, include
from django.contrib import admin
from . import views

urlpatterns = [
    url(r'^myview', views.test),
]
}}}

`testapp/views.py`
{{{#!python
from django.shortcuts import render

# Create your views here.
def test():
    pass
}}}

Which results in this:
{{{#!sh
> python manage.py shell
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type ""help"", ""copyright"", ""credits"" or ""license"" for more information.
(InteractiveConsole)
>>> from django.core.urlresolvers import reverse
>>> from testapp.views import test
>>> reverse(test)
Traceback (most recent call last):
  File ""<console>"", line 1, in <module>
  File ""/home/abrenecki/django/django/core/urlresolvers.py"", line 602, in reverse
    return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)))
  File ""/home/abrenecki/django/django/core/urlresolvers.py"", line 510, in _reverse_with_prefix
    (lookup_view_s, args, kwargs, len(patterns), patterns))
NoReverseMatch: Reverse for 'testapp.views.test' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
>>> exit()
}}}

If I remove the namespace, everything works as expected."	Bug	closed	Core (URLs)	dev	Normal	duplicate			Unreviewed	0	0	0	0	0	0
