Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions django_mongodb/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
"schema.tests.SchemaTests.test_remove_unique_together_does_not_remove_meta_constraints",
"schema.tests.SchemaTests.test_unique_together",
# ManyToManyField
"schema.tests.SchemaTests.test_m2m_create",
"schema.tests.SchemaTests.test_m2m_create_custom",
"schema.tests.SchemaTests.test_m2m_create_inherited",
"schema.tests.SchemaTests.test_m2m_rename_field_in_target_model",
"schema.tests.SchemaTests.test_m2m_repoint",
"schema.tests.SchemaTests.test_m2m_repoint_custom",
Expand Down
8 changes: 8 additions & 0 deletions django_mongodb/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@
class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
def create_model(self, model):
self.connection.database.create_collection(model._meta.db_table)
# Make implicit M2M tables.
for field in model._meta.local_many_to_many:
if field.remote_field.through._meta.auto_created:
self.create_model(field.remote_field.through)

def delete_model(self, model):
# Delete implicit M2m tables.
for field in model._meta.local_many_to_many:
if field.remote_field.through._meta.auto_created:
self.delete_model(field.remote_field.through)
self.connection.database[model._meta.db_table].drop()

def add_field(self, model, field):
Expand Down