Skip to content Skip to sidebar Skip to footer

Django: Filtering Drafts By User Causes Error

I'm trying to filter through a set of drafts objects in a database using the request.user variable. They are For some reason I get the error listed bellow. How can I fix this bug?

Solution 1:

Since request.user is a SimpleLazyObject until it is accessed. Try changing your query to the following:

user_drafts = Draft.objects.filter(user = user.pk)

Solution 2:

The problem is in the line:

user = request.user

Read this post for more details request.user returns a SimpleLazyObject, how do I "wake" it?


Post a Comment for "Django: Filtering Drafts By User Causes Error"