# Is there a proper way to prevent an UpdateView class from modifying a datetime

**URL:** <https://forum.djangoproject.com/t/is-there-a-proper-way-to-prevent-an-updateview-class-from-modifying-a-datetime/15512>\
**Category:** Forms & APIs\
**Created:** [August 20, 2022, 12:42pm UTC](https://forum.djangoproject.com/t/is-there-a-proper-way-to-prevent-an-updateview-class-from-modifying-a-datetime/15512 "2022-08-20T12:42:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Spha](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/spha/32/9509_2.png) [@Spha](https://forum.djangoproject.com/u/Spha)\
**Post date:** [August 20, 2022, 12:42pm UTC](https://forum.djangoproject.com/t/is-there-a-proper-way-to-prevent-an-updateview-class-from-modifying-a-datetime/15512/1 "2022-08-20T12:42:04Z")

</div>

I’ve been trying things so far which did not work.  
I tried pickling the time (encoding the bytes and decoding it back to a datetime), and then saving that as a string in a CharField object, but the UpdateView class (in ref. to class-based views) would then convert it to None.  
Now I’m thinking of overriding the DateTimeField object and using pickle inside of that, but I might be wasting my time. Is there any proper way to prevent an UpdateView class from modifying a DateTimeField object which uses timezone.now?

edit -  
I tried hardcoding the time with form input on the DateTimeField object, but UpdateView will still override it.

---

<div class="post-metadata">

**Author:** ![Spha](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/spha/32/9509_2.png) [@Spha](https://forum.djangoproject.com/u/Spha)\
**Post date:** [August 20, 2022, 1:34pm UTC](https://forum.djangoproject.com/t/is-there-a-proper-way-to-prevent-an-updateview-class-from-modifying-a-datetime/15512/2 "2022-08-20T13:34:02Z")

</div>

the solution was to put the same form field call from my “create form” template into the “update form” template, and then Django maintains the time and date. How that’s happening in the background - I’m not sure.
