forms: get_changed_data(): Remember old values

104 views
Skip to first unread message

Thomas Güttler

unread,
Apr 24, 2014, 9:10:20 AM4/24/14
to django-d...@googlegroups.com
Hello,

I want to improve this method:

django/forms/forms.py: Form.get_changed_data()

I need to have access to the old data, and would like to have a triple list like this:

(field_name, old_value, new_value)

Code: https://github.com/django/django/blob/master/django/forms/forms.py#L415

My current solution is to subclass Form and overwrite this method.

This overwrite is mostly a cut+paste of django's implementation and stores the triple list
on the form instance.

I guess this triple list would be useful for other people, too.

What do you think?

Is there interest do make the above triple list available in django core?

Thomas

Claude Paroz

unread,
Apr 24, 2014, 2:47:58 PM4/24/14
to django-d...@googlegroups.com
Le jeudi 24 avril 2014 15:10:20 UTC+2, guettli a écrit :
Hello,

I want to improve this method:

django/forms/forms.py: Form.get_changed_data()

There are no get_changed_data() method currently, I suppose you meant Form.changed_data (property).

I need to have access to the old data, and would like to have a triple list like this:

(field_name, old_value, new_value)

Code: https://github.com/django/django/blob/master/django/forms/forms.py#L415

My current solution is to subclass Form and overwrite this method.

This overwrite is mostly a cut+paste of django's implementation and stores the triple list
on the form instance.

I guess this triple list would be useful for other people, too.

What do you think?

Is there interest do make the above triple list available in django core?

I think it could be an interesting feature. As often, the difficulty might be to find a solution which respects backwards compatibility, which probably means in this case deprecating changed_data and finding a new name.

Claude

 
Reply all
Reply to author
Forward
0 new messages