I've been following James Bennett's "Practical Django Projects"
alongside of Brett Haydon's very helpful post
http://blog.haydon.id.au/2008/08/notes-on-practical-django-projects.html
and came across an issue when wanting to change the format of the URLs
in my blog application.

For any blog entry, the URL will look something like "/blog/2009/feb/
10/some-post/".  My goal is to change it to "/blog/2009/02/10/some-
post/".  Change the month abbreviation to its respective number.

To do this, in my blog's models.py, I changed the get_absolute_url
function to this:

def get_absolute_url(self):
                return ('coltrane_entry_detail', (), { 'year': 
self.pub_date.strftime
("%Y"),
                                                                                
           'month': self.pub_date.strftime("%m"),
                                                                                
           'day': self.pub_date.strftime("%d"),
                                                                                
           'slug': self.slug })

In the entries urls, I changed the regex to look for digits instead of
word characters:

urlpatterns = patterns ('django.views.generic.date_based',
        (r'^$', 'archive_index', entry_info_dict,
'coltrane_entry_archive_index'),
        (r'^(?P<year>\d{4})/$',
        'archive_year', entry_info_dict, 'coltrane_entry_archive_year'),
        (r'^(?P<year>\d{4})/(?P<month>\d{2})/$',
        'archive_month', entry_info_dict, 'coltrane_entry_archive_month'),
        (r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/$',
        'archive_day', entry_info_dict, 'coltrane_entry_archive_day'),
        (r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/(?P<slug>[-\w]+)/
$',
        'object_detail', entry_info_dict, 'coltrane_entry_detail'),
)

I thought this would have taken care of the URLs, but I'm getting a
404 page with no helpful error message (debug=True) when I try to
access any of my entries or index lists.  "/blog/2009/02/..." doesn't
work.

Usually it would say there are no flatpages for the query, now it's
just blank for that line.

What am I missing?  I feel like it's one of those "urdoinitwrong"
times...

Thanks for your help!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to