Closed OskarPersson closed 7 years ago
I took a quick look into this, but I couldn't replicate it, and unfortunately I don't have time to fully set up a duplicate test case. Do you happen to have a repo I can clone with this issue set up? Thanks!
I created a repo for you to test here. You should only have to create a book, an author and a user that are all connected to get the error described above when you visit /api/books
Just an update, after digging deep into DRF and Django internals, I've tracked down the source of this issue. It's the hack I put in to disallow lookups of a Hashid*Field by integer, and force lookups only by string. I have an idea of how to fix it and will be working on it soon. I'm going to have to set up custom Lookup classes for the different kinds of possible lookups that I want to support, and check for integer lookups there, so that get_prep_value
can take either an int or a string. In the meantime, turning off HASHID_FIELD_ALLOW_INT
or setting allow_int=True
on the particular field will get around the issue. Obviously not a great fix, so I will be attempting to fix this properly soon.
Thanks for the repo, it was a huge help in being able to debug.
This is now fixed in version 1.3.0.
With the models and serializers below I get an exception when listing the books:
Removing the nested serialization of authors in the book serialization gets rid of the exception but displays an invalid id for the author of each book.
Models
Serializers