B
B
Boldy2015-12-30 18:29:13
Django
Boldy, 2015-12-30 18:29:13

Why doesn't update work in django?

there is a code

print self.bar
print baz(apply_date, n=1, include_today=False)
print Foo.objects.all().filter(id=self.id).update(
            bar=baz(apply_date, n=1, include_today=False))
print self.bar

which outputs
None
2014-02-01
1
None

What can be wrong?
Foo.objects.filter(id=self.id).update(
            bar=baz(apply_date, n=1, include_today=False))
also tried

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kazmiruk, 2015-12-30
@Boldy

Because update is gone, but nobody updated your current object. Judging by the response from the update, the change has occurred. It's just that now your current object is out of date and you need to request it again from the database so that it becomes relevant.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question