#26039: Bug with Views being nested partials
-----------------------------+---------------------------------
     Reporter:  gst          |      Owner:  nobody
         Type:  Bug          |     Status:  new
    Component:  Core (URLs)  |    Version:  master
     Severity:  Normal       |   Keywords:  reverse partial url
 Triage Stage:  Unreviewed   |  Has patch:  1
Easy pickings:  0            |      UI/UX:  0
-----------------------------+---------------------------------
 If you define a view `v2` like this:

 {{{
 def view(request):
     pass

 v1 = functools.partial(view)
 v2 = functools.partial(v1)
 }}}

 then set `v2` as the view for some url, then you'll get an attribute error
 if you try reverse() on it :

 AttributeError: 'functools.partial' object has no attribute '__module__'

 {{{
   File "/home/gstarck/work/public/python/django-
 all/django/django/urls/base.py", line 91, in reverse
     return force_text(iri_to_uri(resolver._reverse_with_prefix(view,
 prefix, *args, **kwargs)))
   File "/home/gstarck/work/public/python/django-
 all/django/django/urls/resolvers.py", line 323, in _reverse_with_prefix
     self._populate()
   File "/home/gstarck/work/public/python/django-
 all/django/django/urls/resolvers.py", line 183, in _populate
     self._callback_strs.add(pattern.lookup_str)
   File "/home/gstarck/work/public/python/django-
 all/django/django/utils/functional.py", line 35, in __get__
     res = instance.__dict__[self.name] = self.func(instance)
   File "/home/gstarck/work/public/python/django-
 all/django/django/urls/resolvers.py", line 141, in lookup_str
     return callback.__module__ + "." + callback.__class__.__name__
 AttributeError: 'functools.partial' object has no attribute '__module__'
 }}}

 I have a patch / test case for this..

--
Ticket URL: <https://code.djangoproject.com/ticket/26039>
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/046.a10eb1c4ad087718c72e9c2abb044dd6%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to