django 1.5 1.6 compatibility fixes from https://github.com/gregmuellegger/django-sortedm2m/blob/master/sortedm2m/fields.py.
Included fixes until commit https://github.com/gregmuellegger/django-sortedm2m/commit/3b92cba801a747a9dd826a165a07aa0b469b2e6f