2014年2月13日 星期四

[python][django]model get_or_create return tuple object and created(boolean)


get_or_create

get_or_create(**kwargs)
A convenience method for looking up an object with the given kwargs, creating one if necessary.
Returns a tuple of (object, created), where object is the retrieved or created object and created is a boolean specifying whether a new object was created.

ref:
QuerySet API reference | Django documentation | Django
https://docs.djangoproject.com/en/1.5/ref/models/querysets/#django.db.models.query.QuerySet.get_or_create
python - How does the get_or_create function in Django return two values? - Stack Overflow
http://stackoverflow.com/questions/4706697/how-does-the-get-or-create-function-in-django-return-two-values
django - Correct way to use get_or_create? - Stack Overflow
http://stackoverflow.com/questions/1941212/correct-way-to-use-get-or-create

沒有留言:

張貼留言