Re: m2m assignments lost when saving in admin but not shell

2011-08-24 Thread Shawn Milochik
In case anyone's interested: I still don't know what the problem was, but I solved it by just doing a delay call to a Celery task, so it happens asynchronously. I was already using Celery/RabbitMQ, and the functionality was one of the things I wanted to make async anyway. -- You received

Re: m2m assignments lost when saving in admin but not shell

2011-08-18 Thread Shawn Milochik
On 08/18/2011 09:24 AM, Andre Terra wrote: Your instance is probably not yet saved to the database, so the m2m-related objects don't know which instance to connect to. There's problem something wrong in your save() method. I often use "assert False, some_var" to check if at some point the

Re: m2m assignments lost when saving in admin but not shell

2011-08-18 Thread Andre Terra
Your instance is probably not yet saved to the database, so the m2m-related objects don't know which instance to connect to. There's problem something wrong in your save() method. I often use "assert False, some_var" to check if at some point the variable is already set or not. And I get the same

Re: m2m assignments lost when saving in admin but not shell

2011-08-18 Thread Tom Evans
On Thu, Aug 18, 2011 at 4:44 AM, Shawn Milochik wrote: > I have some code that modifies related items when a model is saved. I've > tried this by both using a post_save signal and by putting the code directly > in a save() override. > > When I save an instance in the Django

Re: m2m assignments lost when saving in admin but not shell

2011-08-17 Thread Matt Schinckel
I had similar problems, but I put it down to doing something 'unusual'. Try setting a pdb breakpoint in your admin class, and see if there is anything odd. I found that I was getting failures due to save(commit=False) meaning that an object had no primary key, and I had to do some fancy stuff

m2m assignments lost when saving in admin but not shell

2011-08-17 Thread Shawn Milochik
I have some code that modifies related items when a model is saved. I've tried this by both using a post_save signal and by putting the code directly in a save() override. When I save an instance in the Django admin, it never works. When I save an instance in ./manage.py shell it always works.