applied patches from https://code.djangoproject.com/attachment/ticket/16778

Conflicts:
	django/contrib/gis/db/backends/postgis/adapter.py