Skip to content

301 Moved Permanently Response #1

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

Closed
kieranhall opened this issue Jul 23, 2014 · 3 comments
Closed

301 Moved Permanently Response #1

kieranhall opened this issue Jul 23, 2014 · 3 comments

Comments

@kieranhall
Copy link

The RESTAdapter doesn't append a slash "/" to the end of collection requests, which Django REST is expecting. I have worked around the problem by overwriting the buildURL method of the RESTAdapter using the following:

buildURL: function(type, id) {
    var url = this._super(type, id);
    if (url.charAt(url.length -1) !== '/') {
        url += '/';
    }
    return url;
}

Is it possible to change the API behaviour within the scope of this package? If not, then it would seem this RESTAdapter change is required.

@jerel
Copy link
Member

jerel commented Jul 23, 2014

There's two ways around this as far as I know.

  1. If you are using Django Rest Framework's SimpleRouter then instantiate it like so router = routers.SimpleRouter(trailing_slash=False) and routes it generates won't require a trailing slash. If you aren't using SimpleRouter then set APPEND_SLASH = False and modify your url regex to match routes without a trailing slash.
  2. Edit the Ember Data application adapter to add the trailing slash like you did.

I'll add your example to the documentation for anyone else that has this problem and may not understand where it comes from.

@kieranhall
Copy link
Author

Sounds good, Jerel. I was thinking that a sample Ember app would be a great addition too. Especially with examples showing relationships between models. What do you think?

@jerel jerel closed this as completed in aac088d Jul 29, 2014
@jerel
Copy link
Member

jerel commented Jul 29, 2014

I agree that it would be nice to have a full Ember app for an example. However I don't have the time to do it at the moment, perhaps someone else can put one up or I can open source a project soon.

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

No branches or pull requests

2 participants