-
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
with reversion.create_revision() and my_model.objects.select_related('XXX').update_or_create #570
Comments
Using transaction.atomic() isn't usually necessary, since Is my_model registered with django-reversion? On Mon, 22 Aug 2016 at 16:25 murdav [email protected] wrote:
|
Dear Author, |
Out of interest, does replacing the I'm wondering if update_or_create always calls save(), when the model is updated. |
Dear @etianen, I tried with:
But without having success, I got the same app behavior, basically no revision was added, while my_instance is correctly retrieved and used in other parts of the function. But if I remove the decorator D |
Hrm.... I don't really know what to say. The exact same code is used in the admin Try this inside that function: print(reversion.is_registered(MyModel)) On Tue, 23 Aug 2016 at 14:13 murdav [email protected] wrote:
|
It returns True. I suppose it is somehow related to have |
I think something has gone a bit wrong somewhere, probably in your code, Time to debug! Try adding loads of print() statements in the reversion On Wed, 24 Aug 2016 at 14:52 murdav [email protected] wrote:
|
Was there a solution to this? I am seeing the same behavior, where a call to
results in the model instance being updated successfully in the database, but reversion does not record a change or new version. |
Does it work if you use |
It works if I use |
I'm afraid this is a mystery to me. Looking at the source code for
update_or_create, it seems to delegate to Model.objects.create() or
Model.save(), both of which should trigger a revision.
If you can get to the bottom of this, I'd take a MR to fix it.
…On Sat, 5 Sep 2020 at 15:12, Stephen Kelly ***@***.***> wrote:
It works if I use .create() but that forces me to re-write the logic
bundled into update_or_create() which I wanted to use
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#570 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABEKCF5D6FFO3SD5HBI2EDSEJBLBANCNFSM4CNH6X3Q>
.
|
Hello,
This is the code:
The revision is not saved, but within update_or_create we have obj.save.
Anyway I don't have any error.
Is there any issue having the decorator @transaction.atomic?
Using the Django admin everything works.
Thanks,
D
The text was updated successfully, but these errors were encountered: