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
KeyError in a del #132
Comments
Please can you provide steps to reproduce this? |
Its a bit tricky but for (still) unknown reasons my code don't appears in the stack. I have a model Event (inherited from wagtail Page) and a model EventRange related via a parental key to Event. I overridden Event.save in order to fill begin/end from its related ranges. But it didn't worked properly (self.ranges was empty). So I reversed the logic: overriding EventRange.save() to update and save (only when needed) the Event object. Modulo avoiding the KeyError in my venv, the reversed logic worked as expected. |
Will close for now - happy to reopen if you can provide full steps to reproduce. |
I did it there : https://forge.cliss21.org/fpoulain/issue132 you should:
|
I also added a branch |
This bug is quite blocking for me. Is there anyway I can help? |
Looking it closer I found why. So I share it. By using WagtailModelAdmin, the Create/Edit form inherit from ClusterForm and in it's save() method the parent and the related are saved sequentially as usually with django related inline forms. So that normal that in the model's save method the child objects aren't accessible. Here we have to catch form's save method and not model's save method. I didn't seen ClusterForm at first stuff because genericity of WMA makes it a bit tricky. And modelcluster docs don't suggest the existence of the ClusterForm mixin. Thanks you so long for all wagtail. |
Glad you got it sorted! Yes, I think the custom logic on |
Hi,
I encountered a KeyError in a del:
I am using :
Django 2.2.15
django-modelcluster 5.0.2
wagtail 2.7.4
The text was updated successfully, but these errors were encountered: