#36847: FileField(upload_to=...) callback no longer sees `auto_now_add ` field
-------------------------------------+-------------------------------------
Reporter: Ran Benita | Owner: Nashrh
| Ashraf Khan
Type: Bug | Status: closed
Component: Database layer | Version: 6.0
(models, ORM) |
Severity: Release blocker | Resolution: needsinfo
Keywords: upload_to, | Triage Stage: Accepted
auto_now_add, pre_save |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Jacob Walls):
> I believe that landing a patch here should be seen as a way to correctly
invoke the saving machinery (we've historically called pre_save with
add=True) over a long term commitment over model field definition order
dictating attribute presence on model instances.
I'm on board with that. Should we then add a caveat on `pre_save()` that
it should be idempotent? We advertise a similar caveat on
`AppConfig.ready()`:
> In the usual initialization process, the ready method is only called
once by Django. But in some corner cases, particularly in tests which are
fiddling with installed applications, ready might be called more than
once. In that case, either write idempotent methods, or put a flag on your
AppConfig classes to prevent rerunning code which should be executed
exactly one time.
Then again maybe this is less important to note if we assume most use
cases for `pre_save()` involve supplying missing values without side
effects.
--
Ticket URL: <https://code.djangoproject.com/ticket/36847#comment:11>
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 view this discussion visit
https://groups.google.com/d/msgid/django-updates/0107019b99f3775a-b6ad6e9b-2000-4e5c-94e1-c8f69a1bea2e-000000%40eu-central-1.amazonses.com.