How to prevent updating auto_now date field.

75 views
Skip to first unread message

Mambaragi

unread,
Jul 26, 2007, 10:53:43 PM7/26/07
to Django users
Hello,
Django 0.96, Python 2.5.

I have a model which has an auto_now date field for checking update
time.
But as you know there will always be exceptions.

I have to prevent updating auto_nowed field for just one action.

Is it possible?
Or should I remove auto_now and update the date field whenever
updating the model?

Regards,
KwonNam.

Russell Keith-Magee

unread,
Jul 26, 2007, 11:01:26 PM7/26/07
to django...@googlegroups.com
On 7/27/07, Mambaragi <kwon...@gmail.com> wrote:
>
> I have to prevent updating auto_nowed field for just one action.
>
> Is it possible?

It is not possible in 0.96, but it is possible on trunk. A recently
added feature allows you to call:

instance.save(raw=True)

which will prevent any field pre-processing (like auto_add) from being
executed during the save. See:

http://www.djangoproject.com/documentation/db-api/#raw-saves

for details.

Yours,
Russ Magee %-)

oggie rob

unread,
Jul 27, 2007, 12:14:36 AM7/27/07
to Django users
> Is it possible?
> Or should I remove auto_now and update the date field whenever
> updating the model?

If you can't update to trunk, this would probably be your easiest
solution. It should only be a few lines of code.

-rob

Reply all
Reply to author
Forward
0 new messages