In your example, I received 500 errors if a method does not allow
AssertionError:.accepted_renderernotsetonResponse
I replaced the Response method on the parent method call, where I got normal behaviour and error 405.
defdispatch(self,request,*args,**kwargs):ifnothasattr(self,'VIEWS_BY_METHOD'):raiseException('VIEWS_BY_METHOD static dictionary variable must be defined on a ManageView class!')ifrequest.methodinself.VIEWS_BY_METHOD:returnself.VIEWS_BY_METHOD[request.method]()(request,*args,**kwargs)returnsuper().dispatch(request,*args,**kwargs)
Thanks, your solution was very helpful to me.
In your example, I received 500 errors if a method does not allow
I replaced the Response method on the parent method call, where I got normal behaviour and error 405.
This now results in this error
AssertionError: Cannot apply DjangoModelPermissionsOrAnonReadOnly on a view that does not set
.queryset
or have a.get_queryset()
methodThis is what I ended up using:
I had the same issue and found that using a predefined Response type instead of the general Response class fixed it.
E.g.
I haven't tested others, but I assume this would work equally well with an HttpResponse or whichever.