Fixed #16731 -- Made pattern lookups work properly with F() expressions

See https://code.djangoproject.com/ticket/16731#comment:11
I hope it won't adversely affect readability, but if you can limit line lengths to 119 characters that would be good (see ticket #23395).