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

See https://code.djangoproject.com/ticket/16731#comment:11
I eventually managed to make that VM thing work and run the test on Oracle (definitely not simple), and it's green.