#27791: update_or_create() doesn't work properly when model has auto_now=True
-------------------------------------+-------------------------------------
     Reporter:  Andrew Chiw          |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  1.10
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Ryan Castner):

 The fact that you use `unique_together = (("base", "target", "date"),)` is
 causing the error you are seeing, it is trying to put two values in there
 since auto_now adds the current datetime as Tim stated as well as your
 provided datetime value and it can't create two primary keys as it
 violates the single unique primary key constraint generated by those three
 fields.

--
Ticket URL: <https://code.djangoproject.com/ticket/27791#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 [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/072.1a32f92a9a98d71e6f0b3b5384fd2c47%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to