Opened 15 years ago
Last modified 3 years ago
#11760 new New feature
Placeholder for through value in ManyToManyField of abstract class
Reported by: | MS | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.1 |
Severity: | Normal | Keywords: | |
Cc: | django.tickets@… | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
If you have an abstract class with ManyToManyField it is possible to user %(class)s in related_name for generic related name. Same should be possible for through, to define a generic name for through tables.
Example:
class ClassA(models.Model): ... class AbstractClass(models.Model): name = models.ManyToManyField(ClassA, related_name = '%(class)s_name', through = 'ClassA_%(class)s') class MyClass(AbstractClass): ... Class ClassA_MyClass(models.Model) class_a=models.ForeignKey(ClassA) my_class=models.ForeignKey(MyClass)
The applied patch uses the same mechanism as used for related_name.
Attachments (1)
Change History (9)
by , 15 years ago
Attachment: | MtoM_abstract_through.patch added |
---|
comment:2 by , 15 years ago
Cc: | added; removed |
---|
comment:3 by , 15 years ago
Needs tests: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:4 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:7 by , 12 years ago
Component: | Core (Other) → Database layer (models, ORM) |
---|
comment:8 by , 3 years ago
Has patch: | unset |
---|---|
Needs tests: | unset |
Note:
See TracTickets
for help on using tickets.
Patch for django/db/models/fields/related.py to use through in ManyToMany Field of an abstact class