Fixed #14334 -- Query comparision now check for object types.

Couldn't this be done either inside get_lookup_constraint() (found somewhere in models/fields/related.py if I remember correctly)? The method already needs to iterate through the values and do some value conversions. Also, it might make sense to define the check part as a submethod, that is the code in:

```
if (value._meta...)
    pass
else:
    raise ValueError()
```
is duplicated two times, removing that duplication will make the code a bit cleaner to read.

If for some reason doing this as part of get_lookup_constraint() doesn't work, then at least make a separate method for this, build_filter() is already complex enough. And if this is moved to get_lookup_constraint(), again separate method in related.py would be a good idea.