diff --git a/README.rst b/README.rst index 7e051c0..8c300a3 100644 --- a/README.rst +++ b/README.rst @@ -22,6 +22,7 @@ Features: - Embdedded model management - SQL model management - Routing on mongodb of some apps + - South support Extra fields: @@ -31,7 +32,6 @@ Extra fields: TODO (ramdom order): - - south support - gridfs - geofield - set field @@ -53,7 +53,7 @@ DATABASES = { 'PORT': '', }, 'mongodb': { - 'ENGINE': 'mongodj.db', + 'ENGINE': 'mongodj', 'NAME': 'test', 'USER': '', 'PASSWORD': '', @@ -67,7 +67,7 @@ in INSTALLED_APPS 'django.contrib.contenttypes' is required. Activate routing adding:: - DATABASE_ROUTERS = ['mongodj.db.router.MongoDBRouter'] + DATABASE_ROUTERS = ['mongodj.router.MongoDBRouter'] Select apps that you want manage in mongodb:: @@ -75,6 +75,14 @@ Select apps that you want manage in mongodb:: MONGODB_MANAGED_APPS = ['testproj.myapp', ] +South Support +------------- + +Add this line to settings.py to make south happy to use mongodj. + +SOUTH_DATABASE_ADAPTERS = { "mongodb" : "mongodj.south"} + + Extra ----- diff --git a/mongodj/db/mongodj/base.py b/mongodj/base.py similarity index 98% rename from mongodj/db/mongodj/base.py rename to mongodj/base.py index 056368c..4ff4ded 100644 --- a/mongodj/db/mongodj/base.py +++ b/mongodj/base.py @@ -8,7 +8,7 @@ from django.core.exceptions import ImproperlyConfigured from .creation import DatabaseCreation -from .operations import DatabaseOperations +from mongodj.operations import DatabaseOperations class DatabaseFeatures(BaseDatabaseFeatures): distinguishes_insert_from_update = False diff --git a/mongodj/db/mongodj/client.py b/mongodj/client.py similarity index 100% rename from mongodj/db/mongodj/client.py rename to mongodj/client.py diff --git a/mongodj/db/mongodj/compiler.py b/mongodj/compiler.py similarity index 100% rename from mongodj/db/mongodj/compiler.py rename to mongodj/compiler.py diff --git a/mongodj/db/mongodj/creation.py b/mongodj/creation.py similarity index 100% rename from mongodj/db/mongodj/creation.py rename to mongodj/creation.py diff --git a/mongodj/db/mongodj/__init__.py b/mongodj/db/mongodj/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/mongodj/db/mongodj/fields.py b/mongodj/fields.py similarity index 100% rename from mongodj/db/mongodj/fields.py rename to mongodj/fields.py diff --git a/mongodj/db/mongodj/mongodb_serializer.py b/mongodj/mongodb_serializer.py similarity index 100% rename from mongodj/db/mongodj/mongodb_serializer.py rename to mongodj/mongodb_serializer.py diff --git a/mongodj/db/mongodj/operations.py b/mongodj/operations.py similarity index 95% rename from mongodj/db/mongodj/operations.py rename to mongodj/operations.py index c1b3834..e6a55d3 100644 --- a/mongodj/db/mongodj/operations.py +++ b/mongodj/operations.py @@ -2,7 +2,7 @@ from pymongo.objectid import ObjectId class DatabaseOperations(BaseDatabaseOperations): - compiler_module = 'mongodj.db.compiler' + compiler_module = 'mongodj.compiler' def __init__(self, database_wrapper): super(DatabaseOperations, self).__init__() diff --git a/mongodj/db/mongodj/router.py b/mongodj/router.py similarity index 96% rename from mongodj/db/mongodj/router.py rename to mongodj/router.py index 304a66c..0dd54f2 100644 --- a/mongodj/db/mongodj/router.py +++ b/mongodj/router.py @@ -7,7 +7,7 @@ def __init__(self): self.managed_apps = [app.split('.')[-1] for app in getattr(settings, "MONGODB_MANAGED_APPS", [])] self.mongodb_database = None for name, databaseopt in settings.DATABASES.items(): - if databaseopt["ENGINE"]=='mongodj.db': + if databaseopt["ENGINE"]=='mongodj': self.mongodb_database = name if self.mongodb_database is None: raise RuntimeError("A mongodb database must be set") diff --git a/mongodj/db/mongodj/south.py b/mongodj/south.py similarity index 93% rename from mongodj/db/mongodj/south.py rename to mongodj/south.py index c418a46..e5ff4f6 100644 --- a/mongodj/db/mongodj/south.py +++ b/mongodj/south.py @@ -36,4 +36,7 @@ def delete_primary_key(self, table_name): pass def delete_table(self, table_name, cascade=True): + pass + + def connection_init(self): pass \ No newline at end of file diff --git a/testproj/myapp/models.py b/testproj/myapp/models.py index c5cd075..329b14b 100644 --- a/testproj/myapp/models.py +++ b/testproj/myapp/models.py @@ -1,6 +1,6 @@ from django.db import models from django.utils.translation import ugettext_lazy as _ -from mongodj.db.fields import ListField, SortedListField, DictField, SetListField, EmbeddedModel +from mongodj.fields import ListField, SortedListField, DictField, SetListField, EmbeddedModel class StringAutoField(models.AutoField): diff --git a/testproj/settings.py b/testproj/settings.py index 4024676..818b672 100644 --- a/testproj/settings.py +++ b/testproj/settings.py @@ -19,7 +19,7 @@ 'PORT': '', # Set to empty string for default. Not used with sqlite3. }, 'mongodb': { - 'ENGINE': 'mongodj.db.mongodj', + 'ENGINE': 'mongodj', 'NAME': 'test', 'USER': '', 'PASSWORD': '', @@ -99,10 +99,12 @@ 'django.contrib.sites', 'django.contrib.messages', 'testproj.myapp', - + 'south', # Uncomment the next line to enable the admin: 'django.contrib.admin', ) -DATABASE_ROUTERS = ['mongodj.db.router.MongoDBRouter'] +DATABASE_ROUTERS = ['mongodj.router.MongoDBRouter'] MONGODB_MANAGED_APPS = ['testproj.myapp', ] + +SOUTH_DATABASE_ADAPTERS = { "mongodb" : "mongodj.south"}