Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Reorder initializing the view
Determining the version and performing content negotiation should be done before ensuring the permission of the request. The reason is that these information can be used in handling the exceptions. For example different versions may return different error scheme. Also, the rendering class can be used to determine how to exception handler response should be rendered.
  • Loading branch information
nourspace committed Mar 20, 2016
commit 03270431edc8ce88938a2d8495fe125867807cca
10 changes: 5 additions & 5 deletions rest_framework/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,6 @@ def initial(self, request, *args, **kwargs):
"""
self.format_kwarg = self.get_format_suffix(**kwargs)

# Ensure that the incoming request is permitted
self.perform_authentication(request)
self.check_permissions(request)
self.check_throttles(request)

# Perform content negotiation and store the accepted info on the request
neg = self.perform_content_negotiation(request)
request.accepted_renderer, request.accepted_media_type = neg
Expand All @@ -385,6 +380,11 @@ def initial(self, request, *args, **kwargs):
version, scheme = self.determine_version(request, *args, **kwargs)
request.version, request.versioning_scheme = version, scheme

# Ensure that the incoming request is permitted
self.perform_authentication(request)
self.check_permissions(request)
self.check_throttles(request)

def finalize_response(self, request, response, *args, **kwargs):
"""
Returns the final response object.
Expand Down