-
-
Notifications
You must be signed in to change notification settings - Fork 17
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 support for adding on_delete
for ForeignKey
and OneToOneField
#117
Add support for adding on_delete
for ForeignKey
and OneToOneField
#117
Conversation
Thanks for the PR, this will be a very nice one to add. The test failed because I didn't setup codecov correctly, apparently GitHub secrets aren't available to forks, which now that I think about it, makes sense. I've fixed it in #118, you might want to update your fork to get this change. Let me know if you have any questions. Thanks again! |
@browniebroke thanks a bunch for taking a look at that test—I merged in those changes and things are working as expected again! 👍 This is looking pretty good! I've added some unit tests and put it thru its paces with some projects I have running locally. I have an instance where I'd like to use this for a field that subclasses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really good! Thank you for this awesome contribution.
Looking at the test, it looks like you're testing mostly for fixing migration files. Can we add a couple for fixing model definitions as well? For example:
class MyModel(models.Model):
user = models.ForeignKey('auth.User')
I'll look at your question and see if I have a better suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are 2 minor nitpicking that Black doesn't handle properly yet.
Co-authored-by: Bruno Alla <[email protected]>
Co-authored-by: Bruno Alla <[email protected]>
…e. Remove some comments and add a docstring.
Sourcery Code Quality Report (beta)✅ Merging this PR will increase code quality in the affected files by 0.08 out of 10.
Here are some functions in these files that still need a tune-up:
Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! |
@browniebroke thanks for the feedback! I just submitted some changes based on your suggestions. |
on_delete
for ForeignKey
and OneToOneField
Thanks for this awesome contribution! This is a big one, wish I had it back when I upgraded 😄 |
@all-contributors please add @cvanderkolk for code |
I've put up a pull request to add @cvanderkolk! 🎉 |
Adding a feature to handle adding the
on_delete
argument toForeignKey
andOneToOneField
types: https://docs.djangoproject.com/en/dev/releases/1.9/#foreignkey-and-onetoonefield-on-delete-argumentTODO:
models
import if it doesn't existon_delete
call when passed as the second position argumenton_delete
matcher which doesn't seem to be finding things rightStretch:
Add an input so folks can add in subclasses(Edit: Probably going to do this in a future PR)Refs #23