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

Django 1.9 incompatibility #90

Open
fabian-marquardt opened this issue Dec 2, 2015 · 4 comments
Open

Django 1.9 incompatibility #90

fabian-marquardt opened this issue Dec 2, 2015 · 4 comments

Comments

@fabian-marquardt
Copy link

Django 1.9 has been released recently. Using this version, django-mongodbforms fails to load with the following exception:

  File "/usr/lib/python3.5/site-packages/mongodbforms/documents.py", line 11, in <module>
    from django.forms.util import ErrorList
ImportError: No module named 'django.forms.util'

There is already a pull request to fix this issue. Please merge this code to the master branch.

@thomwiggers
Copy link

I've forked this project and released django-mongoengine-forms on PyPI. I've stripped out a lot of the legacy stuff and it should be compatible with Django 1.9.

If you find any issues I'd be very happy to hear them.

@m-vdb
Copy link
Contributor

m-vdb commented Jan 5, 2016

nice @thomwiggers ! I was implementing the 1.9 compats but I'm gonna try to use your fork. We've developed a few useful features and fixes on our side, I might to a PR on your repo :)

@replabrobin
Copy link

Following patch fixes a missing attribute new_objects error with django 1.8.8; I wrong put this into django-mongoadmin issues :( mea maxima culpa

diff --git a/mongodbforms/documents.py b/mongodbforms/documents.py
index 0a432a8..0397c2d 100644
--- a/mongodbforms/documents.py
+++ b/mongodbforms/documents.py
....... see below for structure version :(
saved.append(obj)

@replabrobin
Copy link

sorry that looks awful; I'm not a git person obviously :(, but maybe an old git :)

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)```

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

4 participants