title: Deleting objects in django tastypie
body: <p>I have the following models:</p>
  
  <pre><code>class Poster(models.Model)
       user = models.OneToOneField(User, primary=True)
       userpicture = models.CharField(max_length = 128 =True)
  
  class Posts(models.Model)
       poster = models.ForeignKey(Poster, related_name = 'post_owner')
       url = models.CharField(max_length = 128)
       time = models.DateTimeField(auto_now_add=True)
  
  class Comment(models.Model):
       user = models.ForeignKey(Poster)
       post = models.ForeignKey(Posts)
       time = models.DateTimeField(auto_now_add=True)
       comment = models.CharField(max_length=140)
  </code></pre>
  
  <p>A poster can make a post and other posters can comment on that post. Kind of like how a blog works. I would like to make it so that the post owner has the option to delete his own comments and the comments of other posters on his post.</p>
  
  <p>How can I go about doing this?</p>
  
  <p>I'm currently using Django Tastypie. Here is my current resource:</p>
  
  <pre><code>class DeleteComment(ModelResource):
       class Meta:
            queryset = Comment.objects.all()
            allowed_methods = ['delete']
            resource_name = 'comment-delete'
            excludes = ['id', 'comment', 'post', 'time']
            authorization = Authorization()
            authentication = BasicAuthentication()
            include_resource_uri = False
            always_return_data = True
  </code></pre>
  
  <p>This works however! this allows any user to delete any comment even if its not their own which is not good! How?</p>
  
  <p>By simply sending a <strong>DELETE</strong> request to: myapp.com:8000/v1/posts/comment-delete/<strong>8</strong>/ it deletes the <strong>Comment</strong> object that has an <strong>id</strong> of <strong>8</strong>. This is where the setup is failing.</p>
  
  <p>I need a way so that only the post owner of the post can delete his comments and the comments of others on his post.</p>