api - Restricting Django-Rest-Framework default CRUD operations to only GET and restricting POST, PUT and DELETE -


i using django-rest-framework. while following along tutorial able make crud apis defining modelresource. now, want limit access providing apis , not provide access post, put or delete. tried

allowed_methods = ('get') 

but doesn't anything. also, tried override delete function of modelresource doesn't either , delete still works.

seems straight forward thing, havent been able figure out after spending couple of hours on it.

just saw this. have small error in code. instead of:

 allowed_methods = ('get') 

write

allowed_methods = ('get',) 

note trailing comma, make python treat list 1 string instead of list 3 characters. due fact python treats string list of characters, first row evaluates list ('g','e','t') , none of methods available on class.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -