#13713: Changing ModelMultipleChoiceField in admin is not reflected in override
save() of the same model
----------------------------+-----------------------------------------------
 Reporter:  jonathan_livni  |       Owner:  nobody    
   Status:  new             |   Milestone:            
Component:  Uncategorized   |     Version:  1.2       
 Keywords:                  |       Stage:  Unreviewed
Has_patch:  0               |  
----------------------------+-----------------------------------------------
 Consider the following:


 {{{
 class MyModel1 (models.Model):
     name                = models.CharField(max_length=200)

 class MyModel2 (models.Model):
     my_model_1          = models.ManyToManyField(MyModel1,
 blank=True,null=True)
     city                = models.CharField(max_length=200)

     def save(self, *args, **kwargs):
         print (",".join([mm1.name for mm1 in self.my_model_1.all()]))
         print (self.city)
         super(Filter, self).save(*args, **kwargs)
         print (",".join([mm1.name for mm1 in self.my_model_1.all()]))
         print (self.city)
 }}}

 Admin presents my_model_1 field as ModelMultipleChoiceField widget.
 Try changing this multi-choice field in admin a few times and you'll
 discover the bug...
 self.city prints out with the updated value, the one you entered in the
 admin form, both before and after the super()
 but... self.my_model1 retains the previous values in the printout, both
 before and after the super(), although in the db it is updated after the
 save() completes.

 btw, this is the real but and not
 [http://code.djangoproject.com/ticket/13705 this] - my bad

-- 
Ticket URL: <http://code.djangoproject.com/ticket/13713>
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