Ticket #3098: m2mtabelname.patch

File m2mtabelname.patch, 1.1 KB (added by wolfram.kriesing@…, 18 years ago)
  • django/db/models/fields/related.py

     
    610610            limit_choices_to=kwargs.pop('limit_choices_to', None),
    611611            raw_id_admin=kwargs.pop('raw_id_admin', False),
    612612            symmetrical=kwargs.pop('symmetrical', True))
     613        self.db_table = kwargs.pop('db_table', None)
    613614        if kwargs["rel"].raw_id_admin:
    614615            kwargs.setdefault("validator_list", []).append(self.isValidIDList)
    615616        Field.__init__(self, **kwargs)
     
    632633
    633634    def _get_m2m_db_table(self, opts):
    634635        "Function that can be curried to provide the m2m table name for this relation"
    635         return '%s_%s' % (opts.db_table, self.name)
     636        if self.db_table:
     637            return self.db_table
     638        else:
     639            return '%s_%s' % (opts.db_table, self.name)
    636640
    637641    def _get_m2m_column_name(self, related):
    638642        "Function that can be curried to provide the source column name for the m2m table"
Back to Top