#35499: Issue with auto_now=True DateTimefield and update_fields
-------------------------------------+-------------------------------------
               Reporter:  Mohamed    |          Owner:  nobody
  El-Kalioby                         |
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  4.2
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 Let's assume we have the following model


 {{{
 class Order(models.Model):
      name = models.Charfield(max_length=25)
      status = models.CharField(max_length=50, default="Received")
      order_date = models.DateTimeField(auto_now_add=True)
      last_update = models.DateTimeField(auto_now=True)
 }}}


 Now in one of the views, we want to update the status to "Ready for
 Shipping" so we write the following


 {{{
 order.status = "Ready to Shipping"
 order.save(update_fields=['status'])
 }}}


 The issue now is that the '**last_update**' field won't be updated in the
 database as it was NOT included in the `update_fields`. Which I think is
 dangerous as now the developer has to add the field manually, and even
 there is no warning or exception that he/she didn't add last_update field
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35499>
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 on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018fed3af117-49b9efec-c04e-4e6a-8d66-ec5d9102f50a-000000%40eu-central-1.amazonses.com.

Reply via email to