﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
26695	views.generic.base.View.options() documentation doesn't match code	Marcel Moreaux	nobody	"The documentation for views.generic.base.View.options() says:

> options(request, *args, **kwargs)
> 
> Handles responding to requests for the OPTIONS HTTP verb. Returns a list of the allowed HTTP method names for the view.

However, 

{{{#!python
class Some(View):
    def options(self, request, **kwargs):
        return ['GET', 'OPTIONS']
}}}

Results in
{{{
Traceback (most recent call last):
  File ""/.../django/core/handlers/base.py"", line 235, in get_response
    response = middleware_method(request, response)
  File ""/.../django/middleware/clickjacking.py"", line 31, in process_response
    if response.get('X-Frame-Options') is not None:
AttributeError: 'list' object has no attribute 'get'
}}}

The relevant Django code is:

{{{#!python
def dispatch(self, request, *args, **kwargs):
    if request.method.lower() in self.http_method_names:
        handler = getattr(self, request.method.lower(), self.http_method_not_allowed)
    else:
        handler = self.http_method_not_allowed
    return handler(request, *args, **kwargs)

def options(self, request, *args, **kwargs):
    response = http.HttpResponse()
    response['Allow'] = ', '.join(self._allowed_methods())
    response['Content-Length'] = '0'
    return response
}}}

So, from the looks of it, Django expects `options()` to return a `HttpResponse` object, in line with e.g. `get()` and `post()`, in direct contradiction of the documentation.




[1] https://docs.djangoproject.com/en/1.9/ref/class-based-views/base/#django.views.generic.base.View.options"	Bug	closed	Documentation	1.9	Normal	fixed	http dispatch options httpresponse		Unreviewed	0	0	0	0	0	0
