Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
Added south compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Alberto Paro committed Apr 21, 2010
1 parent 43b93ae commit 855c07f
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 10 deletions.
14 changes: 11 additions & 3 deletions README.rst
Expand Up @@ -22,6 +22,7 @@ Features:
- Embdedded model management
- SQL model management
- Routing on mongodb of some apps
- South support

Extra fields:

Expand All @@ -31,7 +32,6 @@ Extra fields:

TODO (ramdom order):

- south support
- gridfs
- geofield
- set field
Expand All @@ -53,7 +53,7 @@ DATABASES = {
'PORT': '',
},
'mongodb': {
'ENGINE': 'mongodj.db',
'ENGINE': 'mongodj',
'NAME': 'test',
'USER': '',
'PASSWORD': '',
Expand All @@ -67,14 +67,22 @@ 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::

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

Expand Down
2 changes: 1 addition & 1 deletion mongodj/db/mongodj/base.py → mongodj/base.py
Expand Up @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file removed mongodj/db/mongodj/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion mongodj/db/mongodj/operations.py → mongodj/operations.py
Expand Up @@ -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__()
Expand Down
2 changes: 1 addition & 1 deletion mongodj/db/mongodj/router.py → mongodj/router.py
Expand Up @@ -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")
Expand Down
3 changes: 3 additions & 0 deletions mongodj/db/mongodj/south.py → mongodj/south.py
Expand Up @@ -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
2 changes: 1 addition & 1 deletion 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):

Expand Down
8 changes: 5 additions & 3 deletions testproj/settings.py
Expand Up @@ -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': '',
Expand Down Expand Up @@ -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"}

0 comments on commit 855c07f

Please sign in to comment.