I'm trying to add a get_absolute_url method to a Tweet model from
django-syncr and do not understand why the method is not recognized.
class Tweet(models.Model):
pub_time = models.DateTimeField()
twitter_id = models.PositiveIntegerField()
text = models.TextField()
user = models.ForeignKey('TwitterUser')
def __unicode__(self):
return u'%s %s' % (self.user.screen_name, self.pub_time)
def url(self):
return u'http://twitter.com/%s/statuses/%s' %
(self.user.screen_name, self.twitter_id)
@models.permalink
def get_absolute_url(self):
return ('blog_tweet_detail', (), { 'year':
self.pub_time.strftime
("%Y"),
'month':
self.pub_time.strftime("%b").lower(),
'day':
self.pub_time.strftime("%d"),
'slug':
self.tweet.twitter_id })
>>> from syncr.twitter.models import Tweet
>>> t = Tweet.objects.get(pk=1)
>>> t
<Tweet: username 2009-12-17 08:29:17>
>>> t.url
<bound method Tweet.url of <Tweet: username 2009-12-17 08:29:17>>
>>> t.get_absolute_url
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'Tweet' object has no attribute 'get_absolute_url'
--
You received this message because you are subscribed to the Google Groups
"Django users" 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-users?hl=en.