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

Fixed #29871 -- Allowed setting pk=None on a child model to create a copy. #12273

Merged
merged 1 commit into from Jan 15, 2020

Conversation

ChetanKhanna
Copy link
Contributor

@ChetanKhanna ChetanKhanna commented Jan 3, 2020

Ensured that setting pk = None sets all parent_ptr_id's as well as
all AutoField's in the parent heirarchy to None. This follows the
current documentation on copying model instances:
https://docs.djangoproject.com/en/3.0/topics/db/queries/#copying-model-instances
Thanks Simon for the initial patches on Trac!

@ChetanKhanna
Copy link
Contributor Author

I forgot to thank Tim for his work!
#10549

Copy link
Member

@felixxm felixxm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChetanKhanna Thanks for this patch 👍 I left comments.

django/db/models/base.py Outdated Show resolved Hide resolved
django/db/models/base.py Outdated Show resolved Hide resolved
django/db/models/base.py Outdated Show resolved Hide resolved
django/db/models/base.py Outdated Show resolved Hide resolved
tests/model_inheritance_regress/tests.py Outdated Show resolved Hide resolved
tests/model_inheritance_regress/tests.py Outdated Show resolved Hide resolved
@felixxm felixxm changed the title Fixed #29871 -- saving new instance on setting pk = None Fixed #29871 -- Allowed setting pk=None on a child model to create a copy. Jan 13, 2020
django/db/models/base.py Outdated Show resolved Hide resolved
django/db/models/base.py Show resolved Hide resolved
@felixxm
Copy link
Member

felixxm commented Jan 14, 2020

I added test without multi-models inheritance.

@felixxm felixxm force-pushed the fix_29871 branch 2 times, most recently from a1b9bdf to 4fa96fe Compare January 14, 2020 13:02
@felixxm
Copy link
Member

felixxm commented Jan 14, 2020

@ChetanKhanna Thanks for this patch 👍 Welcome aboard ⛵

@charettes Thanks for the review and initial patch 🌟

…copy.

Thanks Simon Charette and Tim Graham for the initial patch.
@felixxm felixxm merged commit 63e6ee1 into django:master Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants