Skip to content

Commit be138ba

Browse files
committed
1 parent 7fba198 commit be138ba

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

mongodbforms/fields.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@
88
from django import forms
99
from django.core.validators import EMPTY_VALUES
1010
from django.utils.translation import ugettext as _
11-
from pymongo.errors import InvalidId
12-
from pymongo.objectid import ObjectId
1311
from django.utils.encoding import smart_unicode, force_unicode
1412
from django.utils.translation import ugettext_lazy as _
1513

14+
try: # objectid was moved into bson in pymongo 1.9
15+
from bson.objectid import ObjectId
16+
from bson.errors import InvalidId
17+
except ImportError:
18+
from pymongo.objectid import ObjectId
19+
from pymongo.errors import InvalidId
20+
1621
class MongoChoiceIterator(object):
1722
def __init__(self, field):
1823
self.field = field

0 commit comments

Comments
 (0)