Are you saving the string representation of the model instance?  I would cast 
the model instance as a str in that case, i.e.  str(instance).

-----Original Message-----
From: [email protected] [mailto:[email protected]] On 
Behalf Of Henrik Baran
Sent: Sunday, November 12, 2017 6:54 AM
To: [email protected]
Subject: [1.11] deviation between .create() and .update()

Hi Django users,

I observed something weird while trying to update an existing database record. 
I create new records by passing a dictionary as **kwargs to .create(). This 
dictionary includes strings, integers and model instances matching with my 
model fields. However, one model field is a CharField that can be populated 
passing a model instance. This works fine for create. But if I try to update 
this record passing the exactly same dictionary as **kwargs to .update(), 
Django raises a TypeError telling me that I cannot update that field because it 
is a CharField and I cannot pass model instances.

... so is this a bug, because it works in .create() or must I adapt my approach?


Thanks a lot for reply.
BR,
Henrik

--
You received this message because you are subscribed to the Google Groups 
"Django users" 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].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7012f455-7483-fab4-92c3-4cf943ef1a09%40posteo.de.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" 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].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1c86ddd84f7a4361b0623ab77f1ea482%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.

Reply via email to