Skip to content

Correct API ROOT to enable parametered urls #3190

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

Merged
merged 2 commits into from
Jul 30, 2015

Conversation

Hachikooking
Copy link

Hi all,

This small modification is needed to be able to completely build parametered urls in the API Root.

@tomchristie
Copy link
Member

Hiya - this needs more detail - could you give an example case please?

@Hachikooking
Copy link
Author

Sure,
I encountered an issue when I tried to use urls beginning by:

'^(?P<my_parameter>.*?)/'

It didn't work as the kwargs (containing the "my_parameter" information) were not provided to the reverse method.
So instead of having an Api Root composed of:
server_url/my_parameter/apples/
server_url/my_parameter/bananas/
etc.
I had nothing in the api root (as no reverse match was found).

@@ -291,6 +291,7 @@ def get(self, request, *args, **kwargs):
try:
ret[key] = reverse(
url_name,
kwargs=kwargs,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presumably if we're doing this then we'd want to include args too?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we should, I just didn't have any use case of not named parameters (as I'm not used to using it).

@tomchristie
Copy link
Member

Similar: #2790

@tomchristie
Copy link
Member

Seems reasonable. Thanks!

tomchristie added a commit that referenced this pull request Jul 30, 2015
Correct API ROOT to enable parametered urls
@tomchristie tomchristie merged commit 1f50f08 into encode:master Jul 30, 2015
@tomchristie tomchristie added this to the 3.1.4 Release milestone Jul 30, 2015
@Hachikooking
Copy link
Author

Thanks a lot for your work! :)

@tomchristie tomchristie modified the milestones: 3.1.4 Release, 3.2.0 Release Jul 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants