1
votes

I'm using tastypie for providing an API for my application. I prefer to have URLs without trailing slashes. I prefer /api/v1/entry/set/1;3 rather than /api/v1/entry/set/1;3/. I've turned off django's APPEND_SLASH and turned on TASTYPIE_ALLOW_MISSING_SLASH.

This works nicely, except for get_multiple (/set) which tastypie notes in its documentation can't work without a trailing slash. The URL regex from the tastypie code is:

# Due to the way Django parses URLs, ``get_multiple`` won't work without
# a trailing slash.
...
url(r"^(?P<resource_name>%s)/set/(?P<%s_list>\w[\w/;-]*)/$" %
             (self._meta.resource_name, self._meta.detail_uri_name),
             self.wrap_view('get_multiple'), name="api_get_multiple"),
...

I've verified that this is true. /api/v1/notes/set/2;1 and /api/v1/notes/set/2;1/ match fine if APPEND_SLASH is enabled, but changing the / in the above regex to /? makes it so django does not match the pattern.

The pattern matches correctly when I try using the re module manually. Why doesn't django match the URL without the trailing slash?

1
What you're doing seems correct. I can only think that perhaps you're not updating the right code... Try replacing the regex with something ridiculous to see. - slackwing
I made sure I'm editing the right code. The comment indicates that this behavior is what's supposed to happen. The question I really have is why - jterrace
That is just the way that tasty pie likes to do things. It is truly annoying. - Jay Taylor
It's actually fixed now, see answer. - jterrace

1 Answers

0
votes

This has been fixed. My pull request was merged June 14th, 2012.