Matt,

You're using get_absolute_url to return an actual view – it's only  
meant to return a string representing the the URL for that model  
instance. The generic view information goes in your URL config file  
only, and get_absolute_url should return a URL that is matched by one  
of the regular expressions in the config. So in your case, it should  
look like this:

def get_absolute_url(self):
     return "/%s/%s/%s/%s/" % (self.year, self.month, self.day,  
self.slug)

That ought to produce a URL that will trigger the date-based object  
detail below.

http://www.djangoproject.com/documentation/model-api/#get-absolute-url

Hope that helps,
Eric


On Apr 20, 2008, at 5:19 AM, Matt wrote:

>
> I'm trying to get the following get_absolute_url function working in
> one of my models:
>
> ============================================================
>    def get_absolute_url(self):
>        return ('django.views.generic.date_based.object_detail', (), {
>            'year': self.start_date.year,
>            'month': self.start_date.month,
>            'day': self.start_date.day,
>            'slug': self.url})
>    get_absolute_url = permalink(get_absolute_url)
> ============================================================
>
> the corresponding URL pattern entry looks like this:
>
> ============================================================
> (r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/(?P<slug>[a-z0-9-]
> +)/$', 'django.views.generic.date_based.object_detail',
> dict(info_dict, month_format = "%m", slug_field='url')),
> ============================================================
>
> So far, I've only got empty strings returned in the template. Can you
> see what I'm doing wrong?
>
> I'm using latest update from trunk.
>
> Many thanks in advance 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to