Skip to content
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

PUT against non-existant url creates object at different url #328

Closed
markotibold opened this issue Oct 28, 2012 · 3 comments
Closed

PUT against non-existant url creates object at different url #328

markotibold opened this issue Oct 28, 2012 · 3 comments

Comments

@markotibold
Copy link
Contributor

I only recently understood that it is allowed to use PUT to create a resource. It might be worth mentioning in the docs that this behaviour is supported by the framework.

Secondly, it doesn't yet fully work as it should. If you put against a url that does not yet exist, an object is created for you, but on a different one. I used the rest_framework_tutorial and it just created a new object with a pk that was the latest +1, which makes sense.

I than tried using slugs as primary keys, but haven't managed to get that working.

@tomchristie
Copy link
Member

The intention is the the .pre_save() method should correctly set the pk or slug field, which I believed was working, but will take a look. I think there should be a test for it, but perhaps I missed it out, again will take a look...

@tomchristie
Copy link
Member

generics.test_put_to_deleted_instance is the relevant test. Would be trivial to duplicate to test_put_as_create

On 28 Oct 2012, at 15:34, Marko Tibold notifications@github.com wrote:

I only recently understood that it is allowed to use PUT to create a resource. It might be worth mentioning in the docs that this behaviour is supported by the framework.

Secondly, it doesn't yet fully work as it should. If you put against a url that does not yet exist, an object is created for you, but on a different one. I used the rest_framework_tutorial and it just created a new object with a pk that was the latest +1, which makes sense.

I than tried using slugs as primary keys, but haven't managed to get that working.


Reply to this email directly or view it on GitHub.

@markotibold
Copy link
Contributor Author

Will do sir.
On Oct 28, 2012, at 6:18 PM, Tom Christie notifications@github.com wrote:

test_put_as_create

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