-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Don't strictly require 'pk' in HyperLinkedRelatedField. #2745
Comments
'pk' is just the default. Use |
Hey @tomchristie, I might be missing something but how would setting the |
Okay, so that line should could be tweaked to...
Would make sense. |
It'd also be worth checking for any other points in the relationships that do the same and also adjusting them. |
Alright I'll put that together and submit a pull request. I had added |
👍 |
…rictly_related Enhancement dont require pk strictly related #2745
The following items had a wrong href value: - Dont require pk strictly for related fields. (encode#2745, encode#2754) - Restrict integer field to integers and strings. (encode#2835, encode#2836)
The associated PR was merged and released in the 3.1.2 release. |
Closing the ticket unless someone can confirm that it shouldn't be :) |
Good point ;) |
A direct check on an object for a
pk
attribute seems to tightly couple the HyperLinkedRelatedField with the Django ORM. It seems to reduce the ability to utilize the HyperLinkedRelatedField with other backends such as DynamoDB, Neo4j, and potentially others. It can be circumvented by adding apk
value to these data stores but I was wondering if it would make sense to instead use a definable attribute that defaulted topk
but could be overwritten if necessary.The
use_pk_only_optimization
function that is used for thePKOnlyObject
optimization could also be used prior to the direct check. I'm not sure if this would generate expected behavior though, as the majority of users who do use the ORM would end up losing the check whenever they changed theirlookup_field
.The text was updated successfully, but these errors were encountered: