django update object code example

Example 1: delete model object django

SomeModel.objects.filter(id=id).delete()

Example 2: django update model

Model.objects.filter(id = 223).update(field1 = 2)

Example 3: django objects.create()

SomeModel.objects.create(firstname='ricky', lastname='ticky')

Example 4: django update request.post

request.POST = request.POST.copy()
request.POST.update({
	"foo":"bar"
})

Example 5: django pk

pk stands the "primary key" in django which represents a models ID. 
The ID attribute is generated for you automatically behind the scences
for each model and any newly created instances after that.

Example 6: create django object

Author.objects.create(name="Joe")

Tags:

Misc Example