-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for namespaces in APIRoot. #2354
Conversation
General approach is spot-on. Some minor review and clean up to follow, but otherwise grand. |
Closes #2351. |
Assume that'll be due to calling the view function directly rather than using 'client.get'. The elegant way to handle this would prob be to have a 'resolver_match' attribute on our request objects that tries accessing the HTTPRequest resolver_match and falls back to reverse on AttributeError. |
eb0b5ca
to
00216e7
Compare
68eb0fa
to
b36a4fd
Compare
@tomchristie, you were right about why That Listless test actually makes the |
I have added the patch as a second commit. Let me know if you have any questions. |
""" | ||
Attempt to retrieve the namespace of the current router. | ||
""" | ||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you create a 'get_resolver_match' function for this and put it in 'compat.py' then we can keep versions branching isolated to that module, and make it easier for us to notice that it needs cleaning up when we drop 1.4 support.
4158486
to
d8a7e65
Compare
@tomchristie, thank you for the good suggestions. I have added them and I squashed my commits. Let me know if there is anything else. |
Closed via efa5942 which is based on your work - thanks! |
thanks @tomchristie |
thanks for your help too @thedrow |
This pull request supercedes #2333, #2350 and is in response to #2351.
Problem
The DefaultRouter API Root does not support namespaced URLs.
How this PR attempts to resolve it
@tomchristie recommended this
So that's how this pull request attempts to resolve the issue.
Things I'm not satisfied with about this PR
The implementation of
get_namespace
is more complicated than it should be, but only because it has to support tests in two ways:'/'
, which triggers a Resolver404.Were it not for those two problems, the implementation would simply be
namespace = request.resolver_match.namespace
.Thank you for your time and patience with this series of pull requests.