Django DB delete filtered Objects

I'm trying to delete a user's all related messages. All messages sent by all users are located in a Message Model. So, to delete a specific user's messages only, I have to filter this Message.Model and sort it by user.

def clear(request):
    user_msg = request.user
    relative_message = Message.objects.filter(user=user_msg)

My code is not working and gives me a Value Error:

The QuerySet value for an exact lookup must be limited to one result using slicing.

You should change your code as below:

def clear(request):
Back to Top