I'm trying to use date-based generic views for each category on my
site so, for example, the news category will have date-based archive
at news/2010/jan/02/slug and features would have features/2010/
… and so on.

I also want site admins to be able to rename categories at will, so I
don't want the names to be hard coded. What I've tried is having this
on my models:

<code>
&hellip;
def get_absolute_url(self):
        return ('newssite_entry_detail', (), { 'cat':
str(self.navigation_parent).lower(),
                                           'year':
self.pub_date.strftime("%Y"),
                                           'month':
self.pub_date.strftime("%b").lower(),
                                           'day':
self.pub_date.strftime("%d"),
                                           'slug': self.slug })

get_absolute_url = models.permalink(get_absolute_url)
</code>

and in my root urls:
<code>
&hellip;
    (r'^(?P<cat>[-\w]+)/$', views.entries_by_category),
    (r'^(?P<cat>[-\w]+)/', include('newssite.urls')),
</code>

with newssite urls just showing typical date-based structure:
<code>
urlpatterns = patterns('django.views.generic.date_based',
                       (r'^(?P<year>\d{4})/$',
                        'archive_year',
                        info_dict,
                        'newssite_entry_archive_year'),
                       (r'^(?P<year>\d{4})/(?P<month>\w{3})/$',
                        'archive_month',
                        info_dict,
                        'newssite_entry_archive_month'),
                       (r'^(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>
\d{2})/$',
                        'archive_day',
                        info_dict,
                        'newssite_entry_archive_day'),
                       (r'^(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>
\d{2})/(?P<slug>[-\w]+)/$',
                        'object_detail',
                        info_dict,
                        'newssite_entry_detail'),
)
</code>

But when I try anything with this it complains about the extra 'cat'
keyword argument, as I expected it to. I thought a wrapper function
would take care of this for me, but I can't get anywhere with writing
one and all the advice I've been able to find only relates to non date-
based generic views. Can anyone point me in the right direction?

Thanks in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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