Skip to content
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

patch to fix saving error related to missing new_objects attribute #36

Open
replabrobin opened this issue Feb 2, 2016 · 1 comment
Open

Comments

@replabrobin
Copy link

Hi, following patch fixes an error in Django 1.8.8 where saving any change causes a missing attribute new_objects traceback.

diff --git a/mongodbforms/documents.py b/mongodbforms/documents.py
index 0a432a8..0397c2d 100644
--- a/mongodbforms/documents.py
+++ b/mongodbforms/documents.py
@@ -703,9 +703,16 @@ class BaseDocumentFormSet(BaseFormSet):
Saves model instances for every form, adding and changing instances
as necessary, and returns the list of instances.
"""
+
saved = []

  •    self.new_objects = []
    
  •    self.changed_objects = []
    
  •    self.deleted_objects = []
    
    • for form in self.forms:
  •        if not form.has_changed() and form not in self.initial_forms:
    
  •        changed = form.has_changed()
    
  •        new = form not in self.initial_forms
    
  •        if not changed and new:
             continue
         obj = self.save_object(form)
         if form.cleaned_data.get("DELETE", False):
    
    @@ -715,6 +722,11 @@ class BaseDocumentFormSet(BaseFormSet):
    # if it has no delete method it is an embedded object. We
    # just don't add to the list and it's gone. Cool huh?
    continue
  •            self.deleted_objects.append(obj)
    
  •        elif new:
    
  •            self.new_objects.append(obj)
    
  •        elif changed:
    
  •            self.changed_objects.append(obj)
         if commit:
             obj.save()
         saved.append(obj)
    
@replabrobin
Copy link
Author

Sorry that patch is mongodbforms. I'll put it there as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant