How to Use Python Shell?

Haebin Ethan Jeong·2020년 6월 15일
0

Bulk Create

We can use bulk_create for creating multiple objects in one shot.

Here is an example.

Category.objects.bulk_create(
[Category(name="God"),
Category(name="Demi God"),
Category(name="Mortal")]
)

Creating an object with a ForeignKey

- Comments.objects.create(author = Users.objects.get(id=1), comment = "so cute")

How to delete objects

Category.objects.filter(id=1).delete() will delete the pre exisiting object.

Objects count

Category.objects.all().count()
profile
I'm a Junior studying Economics and Computer Science at Vanderbilt University.

0개의 댓글