#13369: Should be easier to add a MultipleChoice for reverse relationships on
ModelAdmins
------------------------------------------------+---------------------------
               Reporter:  r0wb0t                |         Owner:  nobody
                 Status:  new                   |     Milestone:        
              Component:  django.contrib.admin  |       Version:  1.2   
             Resolution:                        |      Keywords:        
           Triage Stage:  Accepted              |     Has patch:  0     
    Needs documentation:  0                     |   Needs tests:  0     
Patch needs improvement:  0                     |  
------------------------------------------------+---------------------------
Changes (by cainmatt@…):

 * cc: cainmatt@… (added)
  * version:  1.1 => 1.2


Comment:

 == Solution for !ManyToManyField ==

 It is possible to get the right behavior by adding a !ManyToManyField to
 both models. Then the field will be in both models and appear in the Admin
 tool by default. Example:

 {{{#!python
 class Group(Model):
     members = ManyToManyField('Member', related_name='+')

 class Member(Model):
     groups = ManyToManyField(Group, through=Group.members.through,
 related_name='+')
 }}}

 Note:
 * Using through=Group.members.through prevents manage.py sqlall listing
 the join table twice. It may also prevent duplication in ORM internals
 * related_name='+' prevents models instances from having the group_set /
 member_set reverse lookup fields
 * This is a small violation of DRY; it might be nice to have an option on
 !ManyToManyField() to make the reverse relation a true many to many field
 instead of a reverse many to many field
 * You can still use all the other !ManyToManyField() parameters such as
 db_table, blank, etc

-- 
Ticket URL: <http://code.djangoproject.com/ticket/13369#comment:2>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to