I want request.user to only be able to issue a POST request to create a forum topic in which they are authors. With PUT and DELETE, I can achieve this using has_object_permission , but with POST I cannot do this, I assume, because the object has not been created yet.
class TopicPermission(IsAuthenticatedOrReadOnly): """ Any user should be able to read topics but only authenticated users should be able to create new topics. An owner or moderator should be able to update a discussion or delete. """ def has_object_permission(self, request, view, obj): if request.method in SAFE_METHODS: return True
How can I check request.user == obj.author in POST requests?
django django-rest-framework
awwester
source share