﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33834	Compact way to in-place update of the ORM model instance	Anton Danilchenko	nobody	"Hello,

I think that it will be useful to have such a methods to update the instance in-place, that saves a bit of typing:

{{{
book = Book.objects.get(pk=123)

# Currently we do next
book.title = ""New title""
book.year = 2022
book.save()

# NEW WAY: Set multiple fields in-place
book.set(title=""New title"", year=2022)
book.save()

# NEW WAY: Update multiple fields in-place
book.update(title=""New title"", year=2022)
}}}

This way we can save on typing, and set fields (especially if we have them in a dict) easily. Or we can update an object with new field values and save it explicitly.

It can be implemented easily in the base Model class by adding two methods:

{{{
class Model:
    def set(self, **kwargs):
        for name, value ink wargs.items():
            setattr(name, value)

    def update(self, **kwargs):
        self.set(kwargs)
        return self.save()
}}}

My question is next - why it's no such obvious operations in the Django ORM yet? Is it done by purpose? "	New feature	closed	Database layer (models, ORM)	dev	Normal	duplicate	orm		Unreviewed	0	0	0	0	0	0
