Thanks for your reply, Ryan, but it would be equivalent to simply
calling the self.parent.some_method() from the round save.

And my purpose is to have the signal (or other way of tracking) for
the point when _all_ objects (rounds) related to the specific object
(game) are saved.
Something like admin_form.post_m2m_save
Also notice that this "fixing ordering" method should change all
rounds related to the current game, thus calling their save methods,
which would lead to cyclic calls between save methods of the game and
the round if the game.save is called from the round.save.

Maybe this cycle will always exist and I have to define separate
"freeze" method that will be called before the game begin (consequent
ordering is required only during the game process), or I should extend
the models to work with arbitrary ordering numbers.

On Jul 9, 9:07 pm, Ryan K <ryankas...@gmail.com> wrote:
> Is there any reason you can't create your own signal and put it in the
> rounds save() method and then just call the parents save?
>
> http://docs.djangoproject.com/en/dev/topics/signals/#defining-and-sen...
>
> Cheers,
> Ryan
>
> On Jul 9, 6:12 am, Eugene Mirotin <emiro...@gmail.com> wrote:
>
> > Hello!
>
> > I have a tricky (as seems to me :) problem.
>
> > Consider I have 2 simply related models - a Game and a Round (with FK
> > to Game). Each has some generic fields like name and description.
> > Also, the Round has the ordering field (called number) (oh, I can
> > imagine your sighs =)
> > They are edited on the single admin page for Game with TabularInline
> > for game rounds.
>
> > I know about the way to use jQuery for inlines reordering, but this is
> > not the question. Currently I am exactly interested in the manual
> > number field filling.
>
> > So what happens when I save the game? First, the game itself is saved
> > because of the need of the saved FK object for rounds saving, and I
> > understand it. Then the rounds are saved in order.
> > At this point due to some reason the rounds' numbers might be any
> > numbers. But my applications requires them to be exactly the
> > consequent positive integers starting from 1.
>
> > This could be easily fixed by a simple loop, but it should be done at
> > the appropriate point - on the per-game basis and _after_ all the
> > related objects are saved (otherwise nasty bugs with incorrect
> > ordering are possible).
>
> > So I have to know the moment when all the current game's related
> > objects are saved. And there is no appropriate standard signal for
> > this.
> > Any thoughts?
>
> > Gene
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to