Commits

Ian Lewis committed 52f5f46 Merge

Merged key's changes

  • Participants
  • Parent commits 7850571, 5e5240a

Comments (0)

Files changed (1)

storages/backends/mongodb.py

         db = settings.GRIDFS_DATABASE
         # This should support both the django_mongodb_engine and the GSoC 2010
         # MongoDB backend
-        try:
-            connection = connections[db].db_connection
-        except:
-            connection = connections[db].connection
-        return GridFS(connection)
+        from django_mongodb_engine import __version__
+        if __version__[0] == 0 and __version__[1] <= 3:
+            try:
+                connection = connections[db].db_connection
+            except:
+                connection = connections[db].connection
+            return GridFS(connection)
+        else:
+            return GridFS(connections[db].database)
 
     def _open(self, name, mode='rb'):
         return GridFSFile(name, self, mode=mode)
         return force_unicode(name).strip().replace('\\', '/')
 
     def delete(self, name):
-        file = self.fs.delete(name)
+        f = self._open(name, 'r')
+        return self.fs.delete(f.file._id)
 
     def exists(self, name):
         try:
         raise NotImplementedError()
 
     def close(self):
-        self.file.close()
+        self.file.close()
+