You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would expect foo.refresh_from_db() to exhibit exactly the same behaviour as foo = Foo.objects.get(pk=foo.pk), but foo.get_old_value('blabla') returns the original old value. Here's a sample from a test in an actual project where I wanted to test a validation check is only run when the type or status field changes.
activity = activity_model(
type='other', status='finished', finished_datetime='2017-10-14T13:00:00Z',
start_km=0, end_km=0, start_fuel_level=0, end_fuel_level=0,
assignment=assignment, allocation=allocation,
)
# Hack around a validation which triggers only if type changes by doing a bulk db query to change the type
Activity.objects.filter(id=activity.id).update(type='load')
activity.refresh_from_db()
activity.get_old_value('status') # This returns "other", I would expect "load"
activity = Activity.objects.get(id=activity.id)
activity.get_old_value('status') # This returns "load", as expected
The text was updated successfully, but these errors were encountered:
I would expect
foo.refresh_from_db()
to exhibit exactly the same behaviour asfoo = Foo.objects.get(pk=foo.pk)
, butfoo.get_old_value('blabla')
returns the original old value. Here's a sample from a test in an actual project where I wanted to test a validation check is only run when thetype
orstatus
field changes.The text was updated successfully, but these errors were encountered: