On Sun, Apr 5, 2009 at 4:08 AM, EagerToUnderstand <[email protected]> wrote:
> > With regards to the history log on models in the admin view. > > I am adding instances of models via the db api (model.save()) > method. When such a model is opened (but not edited) and then saved > for the first time in the admin model view a history log entry is > created showing ALL elements of the model has changed. After this you > can open and save the model and the history log behaves as expected. > > I looked into the code and see the has_changed and changed_data dict > is created by calling methods on widgets which takes the > responsibility to compare "new" data with "initial" data. Unless I am > mistaken these widgets think the initial data differs from the > committed (but unchanged) data. I now need to look deeper but hoped > somebody stumbled across something similar that would be willing to > offer help? > > Expected behavior would be that the history log on first model save > (from the admin model view) only show model elements that actually > changed. > > I cannot recreate what you are describing. My own DB is similar to what you describe -- model instances are added not via admin but but by other code that uses the ORM directly. I just tried, and when I went to the change page for one of these model instances in admin and selected "Change History" I first got a note that the object did not have a change history, which makes sense because it had never been changed in admin. I then went back, made no change to the model fields, and selected "Save and continue editing". When I now check the change history it has one item, with an "Action" of "No fields changed." So in general the admin behaves as you are asking it to. Since you've gotten as far as finding the code where this is done, it might be simplest to start printing some initial/submitted values for what it is listing as changed, then perhaps you can spot what the differences it is seeing are. Karen --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---

