Friday, January 15, 2010

Re: Save, Signals and Models

On Friday 15 January 2010 17:11:23 Victor Loureiro Lima wrote:
> I did exactelly that, instead of using id I used the slug, which is also
> unique, so I skipped it,
> but the problem still occurs. Either my logic is wrong, or some dumb
> mistake, but I think that wouldnt work either.
>
> Victor Lima
>

I just rechecked the django docs, the reason post_save() doesn't work is cause
post save is at the _end_ of the save method, end isn't after the save is
executed, but after all the instructions are executed in the save method. Yes
everytime you call save(), even in the loop that bit of code is getting called
all the time.

You should update this in the model admin after the save is complete, send a
custom single or call a manager method (mangers are meant ot work at the table
level, as opposed to models working on the row level) or put this code bit in
a function you call in the model admin after saving. Ideally I would put it
in a custom singal and send that after the save, where ever I needed it.


Mike
--
Do people know you have freckles everywhere?

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate