【发布时间】:2020-12-24 21:27:58
【问题描述】:
当我尝试添加表情符号时,我得到了这个错误,即使 CharField 得到同样的错误也没有锻炼。 models.py
class Comment(models.Model):
post = models.ForeignKey(Post, related_name='comments', on_delete=models.CASCADE)
content = models.TextField(max_length=500, blank=False)
author = models.ForeignKey(User, on_delete=models.CASCADE)
date_created = models.DateTimeField(default=timezone.now)
def __str__(self):
return self.content
def get_absolute_url(self):
return reverse('post-detail', kwargs={'pk': self.post.pk}) # returns a string to the post detail that uses the pk of the comment instance. post. pk to link to the correct detail page ie. /post/
def save(self, *args, **kwargs):
super(Comment, self).save(*args, **kwargs)
n = 4
truncatewords = Truncator(self.content).words(n)
notify.send(self.author, recipient=self.post.author, verb='commented "' + truncatewords + '" on your post!', action_object=self.post, description='comment', target=self)
【问题讨论】:
标签: mysql python-3.x django