#9496: reverse() function doesn't seem to take account of the includer urlconf
------------------------------------+---------------------------------------
          Reporter:  seemant        |         Owner:  nobody
            Status:  new            |     Milestone:        
         Component:  Uncategorized  |       Version:  1.0   
        Resolution:                 |      Keywords:        
             Stage:  Unreviewed     |     Has_patch:  0     
        Needs_docs:  0              |   Needs_tests:  0     
Needs_better_patch:  0              |  
------------------------------------+---------------------------------------
Comment (by gogna):

 this is my test case with django r9699

 blog/models.py:
 {{{
 class Post(models.Model):
     """Post model."""
     title           = models.CharField(_('title'), max_length=200)
     slug            = models.SlugField(_('slug'),
 unique_for_date='publish')
     publish         = models.DateTimeField(_('publish'))

     @permalink
     def get_absolute_url(self):
         return ('blog_detail', None, {
             'year': self.publish.year,
             'month': self.publish.strftime('%b').lower(),
             'day': self.publish.day,
             'slug': self.slug
         })
 }}}
 urls.py:

 {{{
 from django.conf.urls.defaults import *

 urlpatterns = patterns('',
     (r'^blog/(.*)', include('basic.blog.urls')),
 )
 }}}

 blog/urls.py:
 {{{
 from django.conf.urls.defaults import *
 from blog import views as blog_views

 urlpatterns = patterns('',
 url(r'^(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{1,2})/(?P<slug>[-\w]+)/$',
         view=blog_views.post_detail,
         name='blog_detail'),
 )
 }}}

 ./manage.py shell:
 {{{
 >>> from blog.models import Post
 >>> Post.objects.all()
 [<Post: Donec non tortor in arcu mollis feugiat>, <Post: title>]
 >>> p = Post.objects.all()[0]
 >>> p
 <Post: Donec non tortor in arcu mollis feugiat>
 >>> p.get_asbolute_url()
 Traceback (most recent call last):
   File "<console>", line 1, in <module>
 AttributeError: 'Post' object has no attribute 'get_asbolute_url'
 >>> p.get_absolute_url()
 Traceback (most recent call last):
   File "<console>", line 1, in <module>
   File "/Library/Python/2.5/site-packages/django/utils/functional.py",
 line 55, in _curried
     return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs))
   File "/Library/Python/2.5/site-packages/django/db/models/base.py", line
 532, in get_absolute_url
     return settings.ABSOLUTE_URL_OVERRIDES.get('%s.%s' % (opts.app_label,
 opts.module_name), func)(self, *args, **kwargs)
   File "/Library/Python/2.5/site-packages/django/db/models/__init__.py",
 line 30, in inner
     return reverse(bits[0], None, *bits[1:3])
   File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py",
 line 254, in reverse
     *args, **kwargs)))
   File "/Library/Python/2.5/site-packages/django/core/urlresolvers.py",
 line 243, in reverse
     "arguments '%s' not found." % (lookup_view, args, kwargs))
 NoReverseMatch: Reverse for 'blog_detail' with arguments '()' and keyword
 arguments '{'year': 2008, 'slug': u'donec-non-tortor', 'day': 29, 'month':
 'nov'}' not found.
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/9496#comment:3>
Django <http://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 post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to