-
Notifications
You must be signed in to change notification settings - Fork 487
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
DeserializationError: can't revert object with F() function #848
Comments
What do you mean by "object with F() function"?
…On Tue, 8 Sep 2020 at 12:07, Windreams ***@***.***> wrote:
DeserializationError Traceback (most recent call last)
<ipython-input-20-775fb025c638> in <module>
3 data = versions[1].serialized_data
4
----> 5 list(serializers.deserialize("json", data))
~/PycharmProjects/dicago/venv/lib/python3.8/site-packages/django/core/serializers/json.py in Deserializer(stream_or_string, **options)
67 try:
68 objects = json.loads(stream_or_string)
---> 69 yield from PythonDeserializer(objects, **options)
70 except (GeneratorExit, DeserializationError):
71 raise
~/PycharmProjects/dicago/venv/lib/python3.8/site-packages/django/core/serializers/python.py in Deserializer(object_list, using, ignorenonexistent, **options)
143 data[field.name] = field.to_python(field_value)
144 except Exception as e:
--> 145 raise base.DeserializationError.WithData(e, d['model'], d.get('pk'), field_value)
146
147 obj = base.build_instance(Model, data, using)
DeserializationError: ["'F(edits) + Value(1)' value must be an integer."]: (post:pk=1) field_value was 'F(edits) + Value(1)'.
I get the error when I try to revert to old version
Does anyone know the problem?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#848>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABEKCDDLDV3OOUMNYOAP23SEYGADANCNFSM4Q72Q2QA>
.
|
I use |
That's annoying. I had no idea it was even possible to do that. I've used F
expressions on update() calls, but I didn't know it could be set on
instances.
As a workaround, you can use select_for_update() when you load the model.
That allows you to increment the edits fields atomically without using an F
expression.
…On Tue, 8 Sep 2020 at 16:59, Windreams ***@***.***> wrote:
I use F(edits) + Value(1) to increase edits field by 1 when I save obj to
database.
When reversion capture my obj, It contains F(edits) + Value(1) after that
I revert the version I receive the error.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#848 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABEKCDZLWCUEV2ZRPCOO43SEZIFJANCNFSM4Q72Q2QA>
.
|
I had the same issue using this,
but if I use this code, the revision is working fine, but I think this is a little inefficient,
|
I get the error when I try to revert to old version
Does anyone know the problem?
The text was updated successfully, but these errors were encountered: