From 538ffaf6c71944aa4f0d77f1167c2cef570dabe1 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Tue, 14 Jul 2015 11:13:26 +0100 Subject: [PATCH] Store self.action='metadata' for OPTIONS requests on viewsets. Closes #3115. --- rest_framework/viewsets.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rest_framework/viewsets.py b/rest_framework/viewsets.py index e1c5e17f61..819deb430f 100644 --- a/rest_framework/viewsets.py +++ b/rest_framework/viewsets.py @@ -83,6 +83,12 @@ def view(request, *args, **kwargs): if hasattr(self, 'get') and not hasattr(self, 'head'): self.head = self.get + # Explicitly map `options` requests to an (implicit) action named + # 'metadata'. This action doesn't actually exist as a named method, + # because, unlike other methods, we always route to it. + if hasattr(self, 'options'): + self.action_map['options'] = 'metadata' + # And continue as usual return self.dispatch(request, *args, **kwargs)