#25493: Model instances created with unittest.mock can raise confusing errors
-------------------------------------+-------------------------------------
     Reporter:  Josh Smeaton         |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  Database layer       |                  Version:  1.9
  (models, ORM)                      |
     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 Marcelo Galigniana):

 Hello!

 I ran into this error and I also found the exception too confusing. I
 would like to fix it / improve the error message.

 Could be a fix check in `pre_save_val` if the attr value is a primitive
 python value? (Because is getting an <MagicMock id='XXX'>) object)
 
https://github.com/django/django/blob/751d732a3815a68bdb5b7aceda0e7d5981362c4a/django/db/models/sql/compiler.py#L1755

 Thank you!

-- 
Ticket URL: <https://code.djangoproject.com/ticket/25493#comment:3>
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/0107018cae5e6798-944a3841-4d65-43a8-9744-245d04c46495-000000%40eu-central-1.amazonses.com.

Reply via email to