title: Django writing generic update view restricted to certain user
body: <p>I am building a small blog using django.I want to build a function that allow post author to delete and update their own posts.
  Then I find django has LoginMixin for generic view,but it only block those who don't login.</p>
  
  <p>My article Model is like below</p>
  
  <pre><code>class Article(models.Model):
      author = models.ForeignKey(User)
      updated = models.DateTimeField(auto_now=True)
      created = models.DateTimeField(auto_now_add=True)
      title = models.CharField(max_length=50)
      context = models.TextField()
  
      genre_choice = (('O','Others'),('P','Programming'),('L','Learning'),('E','Entertainment'))
  
      genre = models.CharField(max_length=2,choices=genre_choice,default='O')
      def __str__(self):
          return "{} - {}".format(self.title,self.author)
  
      def get_absolute_url(self):
          return reverse("article-detail",args=str(self.id))
  </code></pre>
  
  <p>This is the generic article detail view.</p>
  
  <pre><code>class ArticleDetail(DetailView):
      model = Article
  </code></pre>
  
  <p>I firstly want to add something like this in the detail template:</p>
  
  <pre><code>{% if article.author == user.username%}
   &lt;!-- Some a tag that directs to the update view --&gt;
  {% endif %}
  </code></pre>
  
  <p>Then I realize that this just hides the a tag ,it can't stop other users to touch the update url simply change the url.</p>
  
  <p>Is there anyway in django can restricted the update and delete permissions to the original user by simply using generic view?Even if they directly enter the update url,they will be rejected.</p>