django/django — pull request #706 by mattrobenolt (2013-02-08 01:46:43+00:00)
Title: Casting a SimpleLazyObject to an int failed

Should be pretty self explanatory. We noticed the bug when passing `request.user` into a filter like:

```python
Model.objects.filter(user=request.user)
```

Since Django is attempting to coerce the object to an int, it fails on the SimpleLazyObject yielding:

```
TypeError: int() argument must be a string or a number, not 'SimpleLazyObject'
```

The error can be reproduced simple by doing:

```python
class Foo(object):
__int__ = lambda self: 1

int(SimpleLazyObject(Foo))
```