404
投稿しようとするとエラーが発生します。しかし、エラーはevent objects don't have get_absolute_url() methods
class Event(models.Model):
title = models.CharField(max_length=200)
description = models.TextField()
date = models.DateTimeField()
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
avatar = models.ImageField(upload_to='avatars/events/', null=True, blank=True)
tags = models.ManyToManyField(Tag, null=True, blank=True)
class Meta:
ordering = ['-date']
def __unicode__(self):
return self.title
# I made this, but this doesn't work
def get_absolute_url(self):
return "/event/" + self.id
# it returns :
Exception Type: TypeError
Exception Value: cannot concatenate 'str' and 'int' objects
これを適切に機能させるにはどうすればよいですか?よろしくお願いします。