On Wed, Feb 25, 2009 at 7:55 PM, Margie <margierogin...@yahoo.com> wrote:

>
> Say I create a form that reflects the current state of an object.  The
> user can edit that form, and when they click 'save', I get back the
> new, possibly edited, values via the POST.  In my POST code I do
> something like this:
>
> postDict = request.POST.copy()
> bookForm = BookForm(postDict, instance=bookObj)
> if bookForm.is_valid()
>  bookForm.save()
>
> What do folks typically do to avoid saving the data if nothing has
> been modified in the form?  Is there any django functionality for
> doing this, or do I just write the manual check that compares the
> fields in the form to the fields in the existing object?
>
> I'm not only concerned with the database access.  In addition to
> avoiding the save, I'd like to emit a message to the user that
> reflects what they've done, or not done.  IE, "book foo updated' or
> "book foo unchanged".
>
> Anyway, just curious if others have encountered this.
>
> Margie
> >
> Form's have a method "has_changed" which says whether or not there is
changed data, this should do just what you expect.

Alex


-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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