1
0
mirror of https://github.com/django/django.git synced 2025-10-26 07:06:08 +00:00

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
This commit is contained in:
Russell Keith-Magee
2007-01-25 13:47:55 +00:00
parent 12ad69c0b4
commit 54feaca70f
3 changed files with 82 additions and 22 deletions

View File

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