N
N
Neoliz2016-09-05 09:51:20
Django
Neoliz, 2016-09-05 09:51:20

How to save queryset?

Good evening forum users. Question trace character.
There is a standard model:

class model_(models.Model):
    name = models.CharField("Name", max_length=10, null=False, blank=False)
    look = models.BooleanField(default=False)

So I got a set of queryset of these models, for example: And now how can I change the look field of the entire queryset to True and save it in one query to the database ?? Except how to manually form SQL. Those. preferably via queryset. Option:
_buffer = model_.objects.filter(look=False)
for item in _buffer:
    item.look = True
    item.save()

Not suitable for obvious reasons.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2016-09-05
@timofeydeys

_buffer.update(look=True)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question