Improve mixin's django compatibility. #186

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
3 participants

Django SingleObjectMixin use get_object(queryset=None) for getting
model instance but django-rest-framework use get_instance(**kwargs)

To use class decorator or method decorator which use get_object
method to get the model instance (Eg. universal permission_required
decorator found in django-permission), I simply add get_object method
to ModelMixin and change codes in ReadModelMixin,
UpdateModelMixin and DeleteModelMixin which use get_instance
method previously.

Ofcourse, I confirmed that tests passed :-)

@lambdalisue lambdalisue Improve mixin's django compatibility.
Django SingleObjectMixin use ``get_object(queryset=None)`` for getting
model instance but django-rest-framework use ``get_instance(**kwargs)``

To use class decorator or method decorator which use ``get_object``
method to get the model instance (Eg. universal ``permission_required``
decorator found in django-permission), I simply add ``get_object`` method
to ``ModelMixin`` and change codes in ``ReadModelMixin``,
``UpdateModelMixin`` and ``DeleteModelMixin`` which use ``get_instance``
method previously.

Ofcourse, I confirmed that tests passed :-)
a336681

s/insted/instead/

Oh, thanks. I'll fix

Collaborator

tomchristie commented Aug 23, 2012

Agreed, tho right now I'm going to keep the current version as-is.
Gradually moving towards a backwards-incompatible major relaunch, which have much better mixin compatibility as noted here.

Will be posting to the mailing list soon, but in the meantime work is progressing on:

https://github.com/tomchristie/restframeworkdocs (Tutorial parts 1-3 in particular)
https://github.com/tomchristie/django-serializers forms branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment