Search code examples
pythondjangodjango-extensions

What is .<format> argument for?


  • Django==1.11

  • django-extensions==1.9.7

    /api/userprofiles/<pk>/   poinkbackend.apps.userprofiles.api.viewsets.UserProfileViewset  api:userprofile-detail
    /api/userprofiles/<pk>\.<format>/ poinkbackend.apps.userprofiles.api.viewsets.UserProfileViewset  api:userprofile-detail
    /a
    

Docs say

show_urls - Displays the url routes that are defined in your project. Very crude at this point.

I had searched with format keyword. But the results are not related to my question.

Does it stand for ?format=json argument?

I had tried replacing json by html, xml. I got error in return.

Reference: http://django-extensions.readthedocs.io/en/latest/command_extensions.html?highlight=show_urls


Solution

  • In that URL pattern, format is a keyword argument in the URL pattern (unlike ?format=json where it's in the querystring). A matching URL would be:

    /api/userprofiles/5.json/