djangosnippets.org: Latest snippets tagged with 'compare'https://djangosnippets.org/tags/compare/2011-08-05T15:08:27.145901-05:00Update timestamp If any instance field has changed
2011-08-05T15:08:27.145901-05:00craigrukshttps://djangosnippets.org/snippets/2506/<p>Needed a function to check if any field in an instance has changed. If so update a datetime field to now to keep track of changes. This function is an override of the save function in the model.</p>
Freely redistributableComparing two json like python objects
2010-10-31T14:53:43.355430-05:00nmb10https://djangosnippets.org/snippets/2247/<p>Shows difference between two json like python objects. May help to test json response, piston API powered sites...
Shows properties, values from first object that are not in the second.
</p>
<p>Example:
</p>
<p>import simplejson # or other json serializer
</p>
<p>first = simplejson.loads('{"first_name": "Poligraph", "last_name": "Sharikov",}')
</p>
<p>second = simplejson.loads('{"first_name": "Poligraphovich", "pet_name": "Sharik"}') …</p>
Freely redistributable