This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_and_update_or_create(model, unique, update): | |
""" | |
Given a model, a dictionary of lookup arguments, and a dictionary of update | |
arguments, this convenience function gets an object and updates it in the | |
database if necessary. | |
Returns a tuple (object, int) where int is 0 if the object was not updated, | |
1 if the object was created, and 2 if the object was updated in the | |
database. |