-
Notifications
You must be signed in to change notification settings - Fork 125
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
models with ID columns not named ID cause exception #29
Comments
Does a9f33fe fix this for you? It's in the master branch but not on PyPI yet. |
It does, but it seems like a strange fix to me - it ties whether your pk is named "id" to the default indexing behavior of the serializer, which seem like unrelated concerns? I'd prefer it to use metadata to work out the name of the primary key and then use that, rather than just looking for ID. I don't know the code well enough but maybe default behavior of not setting an index at all would be better, like I said this breaks compatibility with DRF because that passes pk/id columns through to the user if fields aren't restricted. Thanks for the quick reply, sorry I missed the existing issue. |
Ok, that makes sense. I changed the default index to use The indexes not showing up in JSON output is an unintended side effect of using For now, I came up with a custom DRP-specific orient, |
With a model that has an ID column not named ID, and the following code:
when trying to query the class, you get an error KeyError, "id".
Reading that stack trace and the source I see that this is because by default we run "set_index('id') on the df, and this can be fixed in three obvious ways:
WeirdIDModelSerializer._meta.pk.name gives the ID, for my version of Django at least
so something like
The text was updated successfully, but these errors were encountered: