Better foreign field handling and added back test for django < 1.6