You can do this very easily by tweaking your model as follows:

1. Override __init__() and store the value of that field in a
temporary value, such as self.old_status.

2. Override save() and before you call the super() save, check if
self.pk (meaning the instance is not new). If so, and self.old_status
!= self.current_status, you can raise an exception.

For extra credit you might want to tweak your ModelForm so that it
will raise a ValidationError, because otherwise it'll validate and
then you'll get a 500 error when the save() on the model is attempted.
However, I like having the exception raised at the model level because
it will protect your data in case the model is accessed by some means
other than your ModelForm.

Shawn

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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