Usuwanie obiektów w django tastypie

Mam następujące modele:

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)

Plakat może utworzyć post, a inne plakaty mogą komentować ten post. Jakby działał blog. Chciałbym, aby właściciel postu mógł usunąć własne komentarze i komentarze innych plakatów na swoim poście.

Jak mogę to zrobić?

Obecnie używam Django Tastypie. Oto mój obecny zasób:

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

To działa jednak! pozwala to każdemu użytkownikowi usunąć dowolny komentarz, nawet jeśli nie jest to jego własny, co nie jest dobre! W jaki sposób?

Po prostu wysyłając wiadomośćKASOWAĆ Poproś o: myapp.com:8000/v1/posts/comment-delete/8/ usuwaKomentarz obiekt, który maID z8. W tym miejscu konfiguracja kończy się niepowodzeniem.

Potrzebuję sposobu, aby tylko właściciel postu mógł usunąć swoje komentarze i komentarze innych osób na swoim poście.

questionAnswers(2)

yourAnswerToTheQuestion