#21899: Reverse does not work with function and namespace
-----------------------------+--------------------
     Reporter:  tonnzor      |      Owner:  nobody
         Type:  Bug          |     Status:  new
    Component:  Core (URLs)  |    Version:  1.4
     Severity:  Normal       |   Keywords:
 Triage Stage:  Unreviewed   |  Has patch:  0
Easy pickings:  0            |      UI/UX:  0
-----------------------------+--------------------
 '''django.core.urlresolvers.reverse''' does not work with function and
 namespace.

 Example:

 {{{
 >>> from payment.views import *
 >>> reverse('payment:payment.views.paypal_express_confirm') # resolve
 using namespace and view path
 '/payment/paypal_express/confirm/'

 >>> paypal_express_confirm # check function is there
 <function paypal_express_confirm at 0x39f7668>

 >>> reverse(paypal_express_confirm) # try direct resolve
 Traceback (most recent call last):
   File "<console>", line 1, in <module>
   File "django/core/urlresolvers.py", line 476, in reverse
     return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args,
 **kwargs))
   File "django/core/urlresolvers.py", line 396, in _reverse_with_prefix
     "arguments '%s' not found." % (lookup_view_s, args, kwargs))
 NoReverseMatch: Reverse for 'payment.views.paypal_express_confirm' with
 arguments '()' and keyword arguments '{}' not found.

 >>> reverse(paypal_express_confirm, current_app='payment') # try with
 current_app given
 Traceback (most recent call last):
   File "<console>", line 1, in <module>
   File "/home/tonnzor/projects/reelport-
 application/picturepipe/src/django/django/core/urlresolvers.py", line 476,
 in reverse
     return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args,
 **kwargs))
   File "/home/tonnzor/projects/reelport-
 application/picturepipe/src/django/django/core/urlresolvers.py", line 396,
 in _reverse_with_prefix
     "arguments '%s' not found." % (lookup_view_s, args, kwargs))
 NoReverseMatch: Reverse for 'payment.views.paypal_express_confirm' with
 arguments '()' and keyword arguments '{}' not found.

 >>> reverse(paypal_express_confirm, urlconf='payment.urls') # try app urls
 without namespaces or something
 '/paypal_express/confirm/'
 }}}

 Sure it works when you open '''/payment/paypal_express/confirm/'''

 My project:

 '''/urls.py:'''

 {{{
 from django.conf.urls import *

 urlpatterns = patterns('',
     url(r'^payment/', include('payment.urls', namespace='payment',
 app_name='payment')),
 )
 }}}

 '''payment/urls.py:'''
 {{{
 from django.conf.urls.defaults import *

 urlpatterns = patterns('payment.views',
     url(r'^paypal_express/confirm/$', 'paypal_express_confirm'),
 )
 }}}

 '''payment/views.py:'''
 {{{
 from django.http import HttpResponse

 def paypal_express_confirm(request):
     return HttpResponse('Confirm')

 }}}

 Sorry, I didn't get hands to test on master -- but I'm pretty sure it is
 still there.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/21899>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.392782bc7e1ac70884370722ffd7b193%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to