Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

get_or_create in django

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()
Source by docs.djangoproject.com #
 
PREVIOUS NEXT
Tagged: #django
ADD COMMENT
Topic
Name
6+6 =