def delete_comment( request, **kwargs ): comment = get_object_or_404( Comment, pk = kwargs['comment'] ) if( (not PermissionHandler.delete_comment(request.user, **kwargs )) ): # check for permission using the permissions module. dajax = Dajax() dajax.alert('You do NOT have this permission') return dajax.json() for update in Update.objects.filter( comments__in = [comment] ): update.commments.remove(comment) for task in Task.objects.filter( comments__in = [comment] ): task.commments.remove(comment) comment.delete() dajax = Dajax() dajax.script('location.reload(true)') return dajax.json()