Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Excluding primary key from api view breaks POST #400
I tried excluding the primary key in
However, this breaks POSTing to this view, as the post handler tries to get the pk from the database object after inserting.
I was going to submit a failing unit test, but upon further thinking it actually makes sense that this doesn't work. After all, how should a client know which instance it created if the response may not contain the id?
So I guess, it would just be useful to add a hint to the docs explaining this. Something like "Make sure the primary key field is included if you intend to allow POST".
I would add: that he or she is not allowed to exclude primary keys, as long as other methods than GET are allowed. It might make sense to some users to not expose keys on a read only API.
If you don't mind I'd try coming up with a pull request for raising the error (incl. unit test).