Skip to content
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

Django 2 Upgrade (part 3): Force explicitly "on_delete" for foreign keys. #2507

Merged
merged 1 commit into from
Nov 16, 2019

Conversation

noliveleger
Copy link
Contributor

@noliveleger noliveleger commented Nov 15, 2019

This PR contains only changes related to required argument on_delete for ForeignKeys.
The default behaviour in Django 1.x was on CASCADE.

On top of #2504

@noliveleger noliveleger changed the base branch from 2489-drop-python2-support to python3-upgrade November 15, 2019 14:45
@noliveleger noliveleger changed the title Django Upgrade: Force explicitly "on_delete" for foreign keys. Django Upgrade (part 1): Force explicitly "on_delete" for foreign keys. Nov 15, 2019
@noliveleger noliveleger requested a review from jnm November 15, 2019 16:10
@noliveleger noliveleger changed the title Django Upgrade (part 1): Force explicitly "on_delete" for foreign keys. Django Upgrade (part 3): Force explicitly "on_delete" for foreign keys. Nov 15, 2019
@noliveleger noliveleger changed the title Django Upgrade (part 3): Force explicitly "on_delete" for foreign keys. Django 2 Upgrade (part 3): Force explicitly "on_delete" for foreign keys. Nov 15, 2019
@noliveleger noliveleger changed the base branch from python3-upgrade to 2489-drop-python2-support November 15, 2019 16:23
@jnm
Copy link
Member

jnm commented Nov 16, 2019

Great, so this just continues the same behavior that we had under Django 1.8: https://docs.djangoproject.com/en/1.8/ref/models/fields/#django.db.models.ForeignKey.on_delete

When an object referenced by a ForeignKey is deleted, Django by default emulates the behavior of the SQL constraint ON DELETE CASCADE and also deletes the object containing the ForeignKey. This behavior can be overridden by specifying the on_delete argument.

@jnm jnm changed the base branch from 2489-drop-python2-support to two-databases November 16, 2019 21:09
@jnm jnm merged commit c17170f into two-databases Nov 16, 2019
@jnm jnm deleted the 2490-django2-part1 branch November 17, 2019 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants