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
Add Natural Key support to ForeignKeyWidget #1371
Add Natural Key support to ForeignKeyWidget #1371
Conversation
I should add that I think it would be pretty feasible to add a Meta variable option for use_natural_foreign_keys that would enable setting it on an entire resource and cascading that down to all ForeignKeyWidgets, for situations where all foreign keys have a natural key and you want to default to that behavior for the model. Haven't had time to dig into how the auto-selecting of widgets works to see how that would be done but I would expect it is doable. |
Hi Ryan - thanks for putting this together. It looks like a useful addition but I would like to suggest some changes. I am most worried that it will impact existing users who have their implemented their own subclasses of The other change I would like to suggest would be to remove the Hopefully not too much to change, and lmk if I can help or you need any clarification. |
Anything else you guys need from me here? @manelclos got a chance to have a look? |
Thanks @pokken-magic - leave it with us and we are planning to get this into release 3. Things can slow down sometimes when we have other commitments. btw - if you are interested, you could join the dev group for this project. It just means helping with triaging issues, reviewing PRs etc. Feel free to email me privately if you need any more information. |
Hey Matthew, I think I would be interested in joining the dev group. I've only got a couple hours a week but happy to help out with such a useful product. |
@pokken-magic Going to get this merged - please can you fix the typos and update changelog? |
Will do
…On Mon, Apr 4, 2022 at 7:17 AM Matt Hegarty ***@***.***> wrote:
@pokken-magic <https://github.com/pokken-magic> Going to get this merged
- please can you fix the typos and update changelog?
thanks
—
Reply to this email directly, view it on GitHub
<#1371 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AO4F7GWD25IUHFZXHAFSIH3VDLFTBANCNFSM5KXIOCZA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
I got all those pushed but I'm not seeing a changelog. Thanks for your attention to detail Matthew! |
Done. I wanted to also add my sincere thanks for all you're doing for this project and holding my hand through my first PR! |
You're most welcome 😄 |
Problem
Foreign key widgets must be manually configured with a list of fields if using natural keys, vs. using the built in Django natural key functionality. Having this tight coupling between what is a natural key and what is specified in the resource requires changes in two places if a natural key function is changed, which seems undesirable.
Solution
I added an optional flag to the foreign key widget to enable it to use natural keys. I named the flag in keeping with other functions that accept natural keys in Django.
Happy to add some more tests if anyone has suggestions, and could definitely change the behavior somewhat.
Acceptance Criteria