# IMPORT
from mysite.books import Publisher
--------------------------------------------------------------------------
# CREATE
p = Publisher(name='Boris', age = 30)
p.save()
OR
Publisher.objects.create(name='Boris', age=30)
--------------------------------------------------------------------------
# UPDATE
p = Publisher.objects.get(id=1)
p.name = 'Tom'
p.save()
--------------------------------------------------------------------------
# GET
Publisher.objects.all()
Publisher.objects.all()[0:2]
Publisher.objects.get(name='Boris')
Publisher.objects.filter(name__contains='Bor')
Pyblisher.objects.order_by('-name')
--------------------------------------------------------------------------
# DELETE
Publisher.objects.get(name='Boris').delete()
Комментариев нет:
Отправить комментарий