Support for the DateTime field where we have set auto_now as True#194
Support for the DateTime field where we have set auto_now as True#194pradeep-sukhwani wants to merge 4 commits intoromgar:developfrom
Conversation
calling .save_dirty_fields() will also check if any DateTime field has auto_now=True
|
Hi thanks for the PR, Is there a particular reason or example code for why you need this change? |
|
@LincolnPuzey Appreciate your response The main reason is we've been evaluating using django-dirtyfields instead of using
It seems that while django-dirtyfields does update all the touched fields. We do have timestamp fields like Perhaps this behaviour of updating timestamp fields also can be made configurable? @pssukhwani Feel free to add if i left out anything or stated something incorrectly. |
|
Hi @LincolnPuzey, Thanks for your response. @sidmitra thanks for the detailed overview. Adding to your point, the last commit also make sure that we consider the timezone if it is enabled. |
Description
Currently the
django-dirtyfieldsdetects the fields which have been updated. This changes is for the fields which gets updated once we save the object. Fields such aslast_updated = models.DateTime(auto_now=True)doesn't get detected. So to make sure that such fields get detected, we have added a check and updated the field's value. We have also made sure that it consider the timezone if the support for timezone is enabled.Test case