From 54feaca70f77b39093fe417dcd89eb7c74930e2e Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Thu, 25 Jan 2007 13:47:55 +0000 Subject: 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 --- django/db/models/fields/related.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'django/db/models/fields') 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" -- cgit v1.3