Opened 10 years ago

Closed 10 years ago

#3098 closed enhancement (fixed)

[patch] rename m2m table

Reported by: wolfram.kriesing@… Owned by: Russell Keith-Magee
Component: Database layer (models, ORM) Version:
Severity: normal Keywords: m2m
Cc: freakboy@…, floguy@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

because i used a legacy app i needed to rename my m2m tables, this tiny patch allows the parameter db_table for ManyToManyField()
i.e. pics = models.ManyToManyField(Pic, db_table='core_pic2subchapter')

Attachments (4)

m2mtabelname.patch (1.1 KB) - added by wolfram.kriesing@… 10 years ago.
m2mtablename-doc.diff (649 bytes) - added by wolfram.kriesing@… 10 years ago.
m2mtablename_update_rev4415.patch (1.9 KB) - added by floguy@… 10 years ago.
Updated this patch for SVN revision 4415.
models.py (2.4 KB) - added by floguy@… 10 years ago.
Unit tests for this patch. To be placed in tests/modeltests/custom_tables/ along with an empty init.py

Download all attachments as: .zip

Change History (10)

Changed 10 years ago by wolfram.kriesing@…

Attachment: m2mtabelname.patch added

comment:1 Changed 10 years ago by Russell Keith-Magee

Type: defectenhancement

Good idea - needs documentation and a test case.

comment:2 Changed 10 years ago by Russell Keith-Magee

Cc: freakboy@… added
Owner: changed from Adrian Holovaty to Russell Keith-Magee
Status: newassigned

Changed 10 years ago by wolfram.kriesing@…

Attachment: m2mtablename-doc.diff added

comment:3 Changed 10 years ago by Simon G. <dev@…>

Keywords: m2m added
Needs documentation: set
Needs tests: set
Triage Stage: UnreviewedAccepted

Changed 10 years ago by floguy@…

Updated this patch for SVN revision 4415.

Changed 10 years ago by floguy@…

Attachment: models.py added

Unit tests for this patch. To be placed in tests/modeltests/custom_tables/ along with an empty init.py

comment:4 Changed 10 years ago by floguy@…

Cc: floguy@… added
Needs documentation: unset
Needs tests: unset

I have made the necessary changes to bring this patch up to date with revision 4415, and have created unit tests. I think that the tests fit best in a new folder under tests/modeltests/ called custom_tables. Also, I'm not quite sure why this was flagged as needs_docs, but it must have just gotten looked over that it already had docs attached on the 18th of December. Hopefully now it'll be ready for inclusion onto the trunk!

comment:5 Changed 10 years ago by Simon G. <dev@…>

Triage Stage: AcceptedReady for checkin

Taking RussellM's comment above as a "yes" on design-decision-needed, I've moved this onto ready-for-checkin.

Thanks!

comment:6 Changed 10 years ago by Russell Keith-Magee

Resolution: fixed
Status: assignedclosed

(In [4429]) Fixed #3098 -- Added db_table parameter to m2m fields, allowing the specification of a custom table name for the m2m table. Thanks, Wolfram Kriesing.

Note: See TracTickets for help on using tickets.
Back to Top