-
-
Notifications
You must be signed in to change notification settings - Fork 366
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
#435 Fix instance creation state check #436
base: master
Are you sure you want to change the base?
Conversation
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.
can you update the tests t verify this change won't regress?
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.
can you make the failing tests pass?
@auvipy I fixed one of two failed tests. Trying to fix last test but can't figure out what is the problem. Stucked with fixing this test https://github.com/jazzband/django-model-utils/blob/master/tests/test_fields/test_field_tracker.py#L590. Can't understand why there is
Will be glad if you can help me. |
@auvipy I'm not sure why a review by me was requested. Was this an error, or do you want me to help with something? |
GitHub shows you recently modified the files that's why I requested a review |
Looking at my previous contributions to this project, the only file I have edited that is in this pull request is |
Looks like at the moment of execution |
Found the problem.
|
Problem
FieldTracker has incorrect behaviour if PK field isn't a
AutoFIeld
. Link to issue #435.Solution
Django has a
ModelState
object to determine if objects is in creation state or already exists in db. Replacingif not self.instance.pk is None
withif self.instance._state.adding
solve the problem.Commandments
CHANGES.rst
file to describe the changes, and quote according issue withGH-<issue_number>
.