On 12/06/2010 04:18 PM, Wayne Smith wrote:
> Then yes, in the clean() method of your Galeria form, you could check the
> number of fotos present and then raise a ValidationError if it is too many,
> along with a custom message for the user.
> 
> Is that what you wish to do?
> 

hi
I think the "clean" method wont solve the problem because at the time it
is called, the inlines from galeria have not been saved yet...


This is what happen when I submit a form with a galeria and two
fotografias. the methods are called in this order:

 1. Galeria.clean - don't know the fotografias yet!

 2. GaleriaAdmin.save_model (before calling super.save_model)

 3. Galeria.save ( before calling super.save)
 4. galeria presave signal
 5. galeria presave signal
 6. galeria postsave signal
 7. galeria postsave signal
 8. Galeria.save ( after calling super.save)

 9. GaleriaAdmin.save_model (after calling super.save_model)

10. Fotografia.save - first foto - only now the fotos are saved...
11. Fotografia.save - second foto


So it seems if someone wants to execute some code after all the form has
been processed, he has to do that somewhere else. [ Maybe in the form
submit view? ]

Anyway if I want to perform a validation there, it is to late.

Maybe the only solution would be to do that in the
GaleriaAdmin.save_model, and have to see the request parameters to know
how many new files have been uploaded...


Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to