[Fixed]-Int() argument must be a string or a number, not 'SimpleLazyObject' django

1👍

✅

follow_from field is a foreign key to the user model. In your filter, you are comparing the ID with an user instance.

Your filter follow_from, should be as it:

follow_from=request.user

But, if you want to compare by id, extract the id from the user instance

follow_from_id=request.user.id

0👍

This is because request.user object is lazy loaded. Change the lookup to:


def follow(request, pk):
following, created = Following.objects.get_or_create(
follow_from_id=request.user.id, <------------------------
follow_to_id=pk)
return redirect('login')

Leave a comment