#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 Simon Charette):

 > Should we then add a caveat on pre_save() that it should be idempotent?

 I think we can't until we adjust `DateField.pre_save` and
 `DateTimeFied.pre_save` to be.
 
[https://github.com/django/django/blob/7c1b3391d35fb10e912783fa6c87712e40de22dc/django/db/models/fields/__init__.py#L1508-L1512
 As of now] they always generate a new value on call and assign it.

 We could gate the `auto_now_add=True and add` generation by the presence
 of the attribute on the provided model instances but we can't do that for
 `auto_now=True` as the call of the function is the ''signal'' that a new
 value should be generated.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36847#comment:12>
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/0107019b9a1380f6-61266efb-abbd-4a78-90ec-a051dabb7533-000000%40eu-central-1.amazonses.com.

Reply via email to