#29173: Document that Model.save() doesn't refresh fields from the database --------------------------------------+------------------------------------ Reporter: Xtreak | Owner: nobody Type: Cleanup/optimization | Status: new Component: Documentation | Version: 2.0 Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 --------------------------------------+------------------------------------
Comment (by Xtreak): Replying to [comment:1 Tim Graham]: > I think that's expected behavior as it would add non-trivial overhead to refresh fields from the database after each `save()`. There might be a hook that would allow you to do that for your custom field. I think we don't need to refresh the value from db. Since we know during `get_prep_value` function call the value to be inserted in the database and we can update the object with the correct value which is inserted at [https://github.com/django/django/blob/a2e97abd8149e78071806a52282a24c27fe8236b/django/db/models/sql/compiler.py#L1217]. I might be wrong here due to my limited knowledge of ORM. However I also think it's a breaking change and it will be good to make a note of this behavior in the documentation than to make this code change. Thanks for all the work. -- Ticket URL: <https://code.djangoproject.com/ticket/29173#comment:2> 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.42c23f5313a917048d89e340526720a7%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.