Maybe it's too hot, and my mind isn't working straight, but I can't
figure out the best way to write my 'get_absolute_url' for objects
that will live in date based URLs, ie.

class Article(models.Model):
    title = models.CharField(...)
    slug = models.SlugField(...)
    pub_date = models.DateField(...)


And I want the url for a given article to be something like

/articles/2006/06/31/slug

Of course, I use the date_based generic views for that, but what about
get_absolute_url? I was thinking something like:

def get_absolute_url(self):
    return "/articles/" + self.pub_date.replace("-","/") + "/" + self.slug

But it seems like there'd be a cleaner way (ie. not having to call 'replace')

Any thoughts?

Jay P.

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to