#15288: ManyToManyField doesn't highlight currently selected items in Admin 
where
target is a proxy object.
--------------------------------------+----------------------
               Reporter:  anonymous   |        Owner:  nobody
                 Status:  closed      |    Milestone:
              Component:  Forms       |      Version:  1.2
             Resolution:  worksforme  |     Keywords:
           Triage Stage:  Unreviewed  |    Has patch:  0
    Needs documentation:  0           |  Needs tests:  0
Patch needs improvement:  0           |
--------------------------------------+----------------------
Changes (by julien):

 * status:  new => closed
 * needs_better_patch:   => 0
 * resolution:   => worksforme
 * needs_tests:   => 0
 * needs_docs:   => 0


Comment:

 I tried to follow your instructions and wrote the following test case, but
 everything seems to work as expected (i.e. the saved options are
 highlighted in the M2M widget):

 Models:
 {{{
 #!python
 from django.db import models
 from django.contrib.auth.models import User

 class Place(models.Model):
     name = models.CharField(max_length=100, blank=True)
     type = models.CharField(max_length=100, choices=(('r', 'Restaurant'),
 ('s', 'Shop')), blank=True)

     def __unicode__(self):
         return self.name

 class RestaurantManager(models.Manager):
     def get_query_set(self):
         return super(RestaurantManager,
 self).get_query_set().filter(type='r')

 class ShopManager(models.Manager):
     def get_query_set(self):
         return super(ShopManager, self).get_query_set().filter(type='s')

 class Restaurant(Place):
     objects = RestaurantManager()

     class Meta:
         proxy = True

 class Shop(Place):
     objects = ShopManager()

     class Meta:
         proxy = True

 class FavoriteRestaurants(models.Model):
     user = models.ForeignKey(User)
     restaurants = models.ManyToManyField(Restaurant)
 }}}

 Admin:
 {{{
 #!python
 from django.contrib import admin

 from models import Restaurant, Shop, FavoriteRestaurants

 admin.site.register(Restaurant)
 admin.site.register(Shop)
 admin.site.register(FavoriteRestaurants)
 }}}

 If I've missed something, then please reopen this ticket and please also
 provide a detailed test case.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/15288#comment:1>
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