X
X
xxx2018-09-03 21:46:14
Django
xxx, 2018-09-03 21:46:14

Custom manager to update all model objects with a specific field?

The user model has a field counters , it is by default = 0. When doing various manipulations, it is incremented. So I need to reset this field to 0 for all users at a certain time. If you do this through a regular manager, then it looks like this:

query = User.objects.all()
query.update(counters = 0)

How to create a custom manager with the name SetCounterToZero and then call it on the model.
User.SetCounterToZero? I read about managers and I didn’t find anything other than a custom queriset with a filter

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question