summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2007-01-25 13:47:55 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2007-01-25 13:47:55 +0000
commit54feaca70f77b39093fe417dcd89eb7c74930e2e (patch)
tree71033901489eff4c38149fd8610ef377bfb907e9 /django
parent12ad69c0b4dc3f5ab89a3ccf330d3815e9811134 (diff)
Fixed #3098 -- Added db_table parameter to m2m fields, allowing the specification of a custom table name for the m2m table. Thanks, Wolfram Kriesing.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4429 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/db/models/fields/related.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
index ef5432686b..7c373792b2 100644
--- a/django/db/models/fields/related.py
+++ b/django/db/models/fields/related.py
@@ -629,6 +629,7 @@ class ManyToManyField(RelatedField, Field):
limit_choices_to=kwargs.pop('limit_choices_to', None),
raw_id_admin=kwargs.pop('raw_id_admin', False),
symmetrical=kwargs.pop('symmetrical', True))
+ self.db_table = kwargs.pop('db_table', None)
if kwargs["rel"].raw_id_admin:
kwargs.setdefault("validator_list", []).append(self.isValidIDList)
Field.__init__(self, **kwargs)
@@ -651,7 +652,10 @@ class ManyToManyField(RelatedField, Field):
def _get_m2m_db_table(self, opts):
"Function that can be curried to provide the m2m table name for this relation"
- return '%s_%s' % (opts.db_table, self.name)
+ if self.db_table:
+ return self.db_table
+ else:
+ return '%s_%s' % (opts.db_table, self.name)
def _get_m2m_column_name(self, related):
"Function that can be curried to provide the source column name for the m2m table"