#27564: `refresh_from_db()` should return the model instance instead of None
------------------------------------------------+------------------------
Reporter: Tom | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Uncategorized | Version: 1.10
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
It is mildly annoying that `refresh_from_db` returns None instead of
`self`. In some scenarios (especially involving tests) it would be quite
nice to be able to do:
`assert model.refresh_from_db().status == SomeEnum.SomeStatus`
With lists of models it's also nice to be able to do:
`assert all(model.refresh_from_db().status == Something for model in
list_of_models)`
Currently because the `refresh_from_db` returns None you cannot do this.
--
Ticket URL: <https://code.djangoproject.com/ticket/27564>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/046.f7bc995cfb55fb6ce0e1bcda7b939ff7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.