That part makes sense, but where would I find the "new" values that have been 
set but not saved when my custom save() method is called? Like

X.a=3
X.b=4
X.save()

I want to see if b is a special value before saving.

-----Original Message-----
From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com] On 
Behalf Of Sam Lai
Sent: Thursday, August 05, 2010 7:58 AM
To: django-users@googlegroups.com
Subject: Re: overriding model.save()

On 5 August 2010 03:05, Sells, Fred <fred.se...@adventistcare.org> wrote:
> I would like to prevent saving a new value if the database contains a
> specific value.  This is on a per field, per record basis.
>
> If I override the save() method; is there a way to find the existing (in
> the DB) values and the new (to be stored) values?

Just perform database queries as per normal inside the save() method.

You have access to the object to be stored as well, see
http://docs.djangoproject.com/en/dev/topics/db/models/#overriding-model-methods

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

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


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