Search code examples
pythonpeewee

get_or_create: is it a 'get' or a 'create'?


AFAIK, peewee's Model.get_or_create() doesn't return a flag that indicates a creation, unlike django's get_or_create(). Is there a good way to check if an instance returned by get_or_create() is freshly created?

Thanks


Solution

  • According to source code, no way to find out. Also, according to documentation, it is not recommended to use this method.

    I suggest to use try/except/else clause.