Django Rest Framework: Disable format extensions

Viewed 7

I would like to do something like this:

from rest_framework import routers

router = routers.DefaultRouter(suffix_required=False)

When I look at the definition of DefaultRouter:

class DefaultRouter(SimpleRouter):
    """
    The default router extends the SimpleRouter, but also adds in a default
    API root view, and adds format suffix patterns to the URLs.
    """
    include_root_view = True
    include_format_suffixes = True

Notice include_format_suffixes is hardcoded to True. I must be missing something, but how to I turn off format extensions preferabley for the whole project, or at least for a certain router? I always use JSON, and do not wish to have these .json extensions in the urls created from ViewSets.

I realize I could use Simple router, but I would the " default API root view, that returns a response containing hyperlinks to all the list views" that the DefaultRouter provides.

0 Answers
Related