request.user
You are right if I want to get user in view, but i want to override the save method of 'Comment' model so the author of article can not create comment on her/his article if I made a mistake in view.
I write a method in comment model:
class ArticleComment(AbstractComment):
article = models.ForeignKey(Article, on_delete=models.CASCADE)
# check user is article author
def is_article_author(self, user):
return self.article.author is user
I know that I can use this method in view and handle this purpose, but my question is that:
is there another way to have access to current user ?