Django changes pub_date when I do .save()

178 views Asked by At

I have a model Question with an IntegerField named flags and a datetime Field called pub_date. pub_date is set to be auto_now=True.
I have a view for changing the flags field. And when I change the flags and do .save() to the Question object, its pub date changes to now.
I wan't the pub_date to be set only when it's being created and not when I'm changing some data in the record. How can I do this?
If you need to see my code, please tell me because I don't think you need to here.

2

There are 2 answers

1
tuna On BEST ANSWER

you should set auto_now_add = True

0
Aldarund On

You can just remove auto_now=True and set the field manually when you want to, in your view.