My problem is that Backbone is trying to do an HTTP request on a URL with a slash at the end, like the following:
:8000/api/v1/update/2/
For some reason, Django (or tastypie) is not accepting URLs with slashes at the end, so the above URL will not work, but this URL does work:
:8000/api/v1/update/2
Backbone-tastypie falls back to oldSync, which is the original sync that comes with Backbone, when not using its overridden sync. I believe that when Backbone-tastypie uses oldSync, it appends a slash at the end of the URLs, which I do not want.
Most of the solutions being suggested are dealing with the opposite problem I have. They are trying to fix the problem where trailing slashes work, but no trailing slashes do not work.
I need to be able to support trailing slashes in addition to non-trailing slashes. This can be fixed in two ways:
-
How do I change the backbone-tastypie code so that no AJAX calls append the slash at the end?
-
How do I make it so that Django/tastypie will treat the above two URLs as the same?
Either one of those will fix my problem, but I cannot figure out how to implement any of them.
For a
Backbonesolution:You can overwrite the default behavior of
Model.url, even using the normal one and making a small modification like the one you are looking for:Same aplies for
Collection.