Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show Filters and Ordering in Django Rest Framework Options Request

I'm using the Django Rest Framework I noticed on the web browseable part of the API there is a button called 'options' when clicked it shows the following...

HTTP 200 OK Vary: Accept Content-Type: text/html Allow: HEAD, GET, OPTIONS
{
    "parses": [
        "application/json", 
        "application/x-www-form-urlencoded", 
        "multipart/form-data"
    ], 
    "renders": [
        "application/json", 
        "text/html"
    ], 
    "name": "Products", 
    "description": "API endpoint."
} 

my question is, is there anyway I could list out here all the filter options an other stuff for this url?

like image 1000
jason Avatar asked Feb 27 '13 16:02

jason


1 Answers

You can make OPTIONS return whatever you want, by overriding the .metadata() method on the view.

See here: https://github.com/tomchristie/django-rest-framework/blob/master/rest_framework/views.py#L340


Update as of 2015: We now have a customizable metadata API that makes this easier: http://www.django-rest-framework.org/api-guide/metadata/

like image 175
Tom Christie Avatar answered Oct 02 '22 10:10

Tom Christie