# How to get form field value before and after submit

**URL:** <https://forum.djangoproject.com/t/how-to-get-form-field-value-before-and-after-submit/34314>\
**Category:** Using the ORM\
**Created:** [August 29, 2024, 3:57pm UTC](https://forum.djangoproject.com/t/how-to-get-form-field-value-before-and-after-submit/34314 "2024-08-29T15:57:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nmilner1234](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/nmilner1234/32/19690_2.png) [@nmilner1234](https://forum.djangoproject.com/u/nmilner1234)\
**Post date:** [August 29, 2024, 3:57pm UTC](https://forum.djangoproject.com/t/how-to-get-form-field-value-before-and-after-submit/34314/1 "2024-08-29T15:57:46Z")

</div>

I have a ModelForm object for an UpdateView and I want to find a way to validate using ` def clean_start(self):` if the start date was altered when the form was submitted. I have found data\_changed but this just lists the fields that have changed, not what the values were before and after. Please can I have a pointer to what I should be doing?

```auto
class EventEditForm(ModelForm):

    class Meta:
        model = Event
        fields = ['name', 'start', 'end', 'description', 'organiser_contact',
                  'team_event', 'active', 'oop_active', 'oop_coded', 'cancelled']
        labels = {'active': 'Event Public',
                  'oop_active': 'Order of Play Published',
                  'logo': 'Event Logo',
                  'oop_coded': 'Restricted Access'}
        widgets = {
            'start': forms.DateTimeInput(format=('%Y-%m-%dT%H:%M'), attrs={'type': 'datetime-local'}),
            'end': forms.DateTimeInput(format=('%Y-%m-%dT%H:%M'), attrs={'type': 'datetime-local'})
        }

    def clean_start(self):
        # How do I get the value of start when the form was first rendered and compare to
        # the value of start now?

```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [August 29, 2024, 4:16pm UTC](https://forum.djangoproject.com/t/how-to-get-form-field-value-before-and-after-submit/34314/2 "2024-08-29T16:16:39Z")

</div>

I _believe_ (but am not sure) that the original value would be available as `self.instance.start`. The current value is in `self.cleaned_data['start']`.

---

<div class="post-metadata">

**Author:** ![white-seolpyo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/white-seolpyo/32/22386_2.png) [@white-seolpyo](https://forum.djangoproject.com/u/white-seolpyo)\
**Post date:** [August 30, 2024, 12:20am UTC](https://forum.djangoproject.com/t/how-to-get-form-field-value-before-and-after-submit/34314/3 "2024-08-30T00:20:13Z")

</div>

form support changed\_data(list[str]).

```auto
form = EventEditForm(initial={'start': {some}}, data={some})
form.is_vaild()
'start' in form.changed_data

```

---

<div class="post-metadata">

**Author:** ![nmilner1234](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/nmilner1234/32/19690_2.png) [@nmilner1234](https://forum.djangoproject.com/u/nmilner1234)\
**Post date:** [August 30, 2024, 9:34am UTC](https://forum.djangoproject.com/t/how-to-get-form-field-value-before-and-after-submit/34314/4 "2024-08-30T09:34:22Z")

</div>

@KenWhitesell your belief was correct - thank you.

@white-seolpyo I’m now realising that I also need to find the field differences in the form\_valid() method and I think what you have written is a clue to that but I can’t believe I have to create the form in the first place with a copy of the original data in order to then compare the data returned to form\_valid? Surely the original data used to generate the form must be somewhere and then changed\_data can be used to identify which fields to look at for changes ? I’m trying to stick to form validation being in the forms.py and actions based on change being inside views.py. Any pointers gratefully received.

---

<div class="post-metadata">

**Author:** ![white-seolpyo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/white-seolpyo/32/22386_2.png) [@white-seolpyo](https://forum.djangoproject.com/u/white-seolpyo)\
**Post date:** [August 31, 2024, 12:22am UTC](https://forum.djangoproject.com/t/how-to-get-form-field-value-before-and-after-submit/34314/5 "2024-08-31T00:22:29Z")

</div>

I don’t understand what you want to say.  
Could you please convey this clearly and easily?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [September 1, 2024, 1:36am UTC](https://forum.djangoproject.com/t/how-to-get-form-field-value-before-and-after-submit/34314/6 "2024-09-01T01:36:31Z")

</div>

> [@nmilner1234](#):
>
> Surely the original data used to generate the form must be somewhere and then changed\_data can be used to identify which fields to look at for changes ?

I’m not sure if you’re still looking for an answer to this question, but if so, the answer is no.

Keep in mind that each instance of your view is a new invocation. There is no persistence of data or objects between when you create the bare instance of the form for the GET and when you recreate the instance to bind the submitted data in the POST.
