django-rest-framework-docs icon indicating copy to clipboard operation
django-rest-framework-docs copied to clipboard

cannot load endpoints from different urls files

Open JakeMana opened this issue 9 years ago • 2 comments

In case someone is using subdomains and his api endpoints are in a separate urls.py file (ex.: api_urls.py) its unable to find the routes. IMHO it would be great to have a setting (variable) in settings.py where this file can be defined and not strictly use the base urls.py.

JakeMana avatar Feb 17 '16 15:02 JakeMana

Hi, I don't know if this solves the issue of using subdomains, but it solves having urls in different files. You can check out this branch https://github.com/alej0varas/django-rest-framework-docs/tree/issue-61. I'm not creating a PR because I haven't tested the code enough.

alej0varas avatar May 24 '16 15:05 alej0varas

This branch does fix an issue I encountered with nested urls includes.

Consider this url structure and snippets of urlpatterns (in which the endpoints are namedspaced to a version (here, v1)):

urls.py  # A
api/
    urls.py  # B
    v1/
        urls.py  # C

--
# urls A
url(r'^api/', include('api.urls')),

# urls B
url(r'^token-auth/$', token.obtain_auth_token),
url(r'^v1/', include('api.v1.urls', namespace='v1')),

# urls C
url(r'^foo/$', views.foo),

While the master branch ApiDocumentation.get_all_view_names resolves the path /api/token_auth/ as expected, the path in C is resolved as /foo/.

This branch resolves it to the expected /api/v1/foo/.

Would be nice to see a version of this branch make it into master to address this issue :)

nealtodd avatar Jul 05 '16 17:07 nealtodd