[Django]-TypeError in view: Field expected a number but got SimpleLazyObject

4👍

After some googling around I found this post by Aaron O. Ellis.

The trick is not to use the kwargs directly but from the view class with self:

my_obj = get_object_or_404(MyModel, pk=self.kwargs.get('pk'))

Hope this helps anybody else as well.

👤Ron

Leave a comment