modified for use with django-rest-framework