On Tue, Aug 18, 2009 at 8:52 AM, Marek Palatinus <ma...@palatinus.cz> wrote:

>
> Hello,
>
> Im doing some validation in ModelAdmin.save_model(). I can cancel
> operation (just dont call parent method), but I also need to show some
> error message to user. Im able to call self.message_user() and show
> INFO message, but how to send ERROR message and maybe show form back
> and force user to correct inputs?
>
> I need validation on level of whole formset, not on field level, so I
> cannot use some custom field to achieve that.
>

What you want is to override the ModelAdmin.form with a custom form and
handle the clean_xxx() methods there. Django form validation is done in the
form objects/classes.

Create a ModelForm (
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/) and then set
your ModelAdmin.form to your new ModelForm.

--~--~---------~--~----~------------~-------~--~----~
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