Salvatore Iovene
unread,Sep 3, 2012, 2:00:08 PM9/3/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django-res...@googlegroups.com
Hi,
I want a certain ModelResource to be read-only.
I've been able to disable the POST method in the ListView, by using ListModelView instead of ListOrCreateModelView, but I can't disable DELETE when looking at an instance.
I've created my own view like this:
from djangorestframework.views import ListOrCreateModelView, InstanceModelView
from djangorestframework.response import Response
from resources import *
class UserProfileInstanceView(InstanceModelView):
resource = UserProfileResource
def delete(self, request, id):
return self.render(Response(405))
That's fine, I get a 405 METHOD NOT ALLOWED if I try to delete an instance, but the API browser view still shows DELETE as an allowed method.
Is there a place I can disable unwanted methods a bit earlier in the code path? I understand that "allowed_methods" has been removed, so what is the correct way to do it?
Thanks!
Salvatore.