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)

MtoM_abstract_through.patch (645 bytes ) - added by MS 15 years ago.
Patch for django/db/models/fields/related.py to use through in ManyToMany Field of an abstact class

Download all attachments as: .zip

Change History (9)

by MS, 15 years ago

Attachment: MtoM_abstract_through.patch added

Patch for django/db/models/fields/related.py to use through in ManyToMany Field of an abstact class

comment:1 by vitaliy, 15 years ago

Cc: django-tickets@… added

Yes, very useful feature!

comment:2 by anonymous, 15 years ago

Cc: django.tickets@… added; django-tickets@… removed

comment:3 by Russell Keith-Magee, 15 years ago

Needs tests: set
Triage Stage: UnreviewedAccepted

comment:4 by Julien Phalip, 14 years ago

Severity: Normal
Type: New feature

comment:5 by Aymeric Augustin, 13 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:6 by Aymeric Augustin, 13 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:7 by Aymeric Augustin, 12 years ago

Component: Core (Other)Database layer (models, ORM)

comment:8 by Mariusz Felisiak, 3 years ago

Has patch: unset
Needs tests: unset
Note: See TracTickets for help on using tickets.
Back to Top