📜  django 中的 get_or_create - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:13.519000             🧑  作者: Mango

代码示例1
try:
    obj = Person.objects.get(first_name='John', last_name='Lennon')
except Person.DoesNotExist:
    obj = Person(first_name='John', last_name='Lennon', birthday=date(1940, 10, 9))
    obj.save()