#9593: permalink breaks when using include() in urls.py
---------------------------+------------------------------------------------
Reporter: IanLewis | Owner: nobody
Status: new | Milestone:
Component: Uncategorized | Version: 1.0
Keywords: | Stage: Unreviewed
Has_patch: 0 |
---------------------------+------------------------------------------------
If you use {{{include()}}} to include urls in another urls.py then include
will fail to generate the proper urls for urls in the included urls.py if
the urls fall in a sub-path.
In the given urls.py
{{{
...
urlpatterns = patterns('',
(r'', include('core.urls')),
(r'^blog/(.*)', include('blog.urls')),
)
...
}}}
and models.py
{{{
...
class Post(models.Model):
"""Post model."""
title = models.CharField(_('title'), max_length=200)
slug = models.SlugField(_('slug'),
unique_for_date='publish')
author = models.ForeignKey(User, blank=True, null=True)
body = models.TextField(_('body'))
publish = models.DateTimeField(_('publish'))
def __unicode__(self):
return u'%s' % self.title
@permalink
def get_absolute_url(self):
# return '/blog/%s/%s/%s/%s' %
(self.publish.year,self.publish.strftime('%b').lower(),self.publish.day,self.slug)
return ('blog_detail', None, {
'year': self.publish.year,
'month': self.publish.strftime('%b').lower(),
'day': self.publish.day,
'slug': self.slug
})
...
}}}
using the [EMAIL PROTECTED] decorator will work for core.urls but it would
not work for blog.urls. The permalink decorator simply returns an empty
string.
--
Ticket URL: <http://code.djangoproject.com/ticket/9593>
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
-~----------~----~----~----~------~----~------~--~---