Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8383931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:17:29+00:00 2026-06-09T17:17:29+00:00

From the source code, you can see that Django 1.4’s Form class has a

  • 0

From the source code, you can see that Django 1.4’s Form class has a has_changed() method and changed_data property which seem rather useful, but are undocumented. My question is: do these work as expected, i.e.:

  • In Form.clean(), Form.has_changed() returns True if any any form data has changed, otherwise False
  • In Form.clean(), Form.changed_data is a list of field names whose values have changed.

If so, are there any specific reasons not to use them, apart from the usual caveats/dangers about using undocumented features (i.e. subject to change, not supported, etc.)?

NOTE 1: For these to work with custom widgets, those widgets need to have a _has_changed() method, which is defined for built in widgets.

NOTE 2: Interestingly, the documentation does include an offhand mention of the Formset.has_changed() method, but not of Form.has_changed().

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:17:31+00:00Added an answer on June 9, 2026 at 5:17 pm

    After studying the Django source further, with helpful hints from Florian’s answer, I can report that has_changed and changed_data do work as described in my question as long as the form has a way to get the initial data to compare the new data against.

    So the question is, how does a form created from POST data know what the initial values of the GET form were? The short answer is it doesn’t — unless you tell it somehow. There are two ways to tell it:

    1. Via the initial keyword argument to the form and/or the initial keyword arguments to the fields, exactly the same way you tell the GET form the initial values. NOTE: If you do this, it’s up to you to make sure you use the same values for your GET and POST forms. This is the only truly reliable way to do it, since you directly control what the initial values are.

    2. You let Django do the work of remembering the initial values from your GET by setting the show_hidden_initial keyword argument to True for each applicable field. For these fields, Django renders a hidden input element with the initial value into the GET form’s HTML. Later, when you call has_changed or changed_data on the POST form, for any field with show_hidden_initial as True Django will automatically get the initial values from the hidden input elements in the POST data (superseding any initial values from initial form or field arguments). NOTE: as with anything relying on POST data, this approach is ultimately unreliable, since the values for the hidden inputs could still be changed despite being hidden.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

By looking at the source code for LinkedHashMaps from Sun, I see that there
How can I get source code from WebBrowser component? I want to get source
I'm try to validate form using jquery validation plugin my from code: source code
I have this source code from 2001 that I would like to compile. It
When I look at the source code for a webpage that has been rendered
I have a base form class that contains a method that returns a DataTable:
I have a Hierarchical project that uses source code from a common system-directory, for
How to build a .bundle from source code? This might sound like a simple
I have built an open-source application from the source code. Unfortunately, the original executable
I am trying to install boto from the source code / pypi, but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.