Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django can';t将正确的对象实例分配给ForeignKey字段_Django_Socket.io - Fatal编程技术网

Django can';t将正确的对象实例分配给ForeignKey字段

Django can';t将正确的对象实例分配给ForeignKey字段,django,socket.io,Django,Socket.io,我想将用户发送的消息保存在Django Socket.IO聊天应用程序中,并使用以下型号: class Conversation(models.Model): """ Conversation with two or more participants. """ name = models.CharField(max_length=20) ... class Message(models.Model): """ Single chat m

我想将用户发送的消息保存在Django Socket.IO聊天应用程序中,并使用以下型号:

class Conversation(models.Model):
    """
    Conversation with two or more participants.
    """
    name = models.CharField(max_length=20)
    ...

class Message(models.Model):
    """
    Single chat message.
    """
    conversation = models.ForeignKey(Conversation,related_name='message_convo')
    content = models.CharField(max_length=10000)
    sender = models.ForeignKey(User,related_name='message_sender')
    sent = models.DateTimeField(auto_now=True)
我的事件处理程序代码包括以下内容:

convo = get_object_or_404(Conversation, id=message["room"])
...
m = Message()
m.conversation = convo,
m.content = message["message"]
m.sender = user
m.save()
这失败了,带来了一条毫无意义的信息:
ValueError:无法分配“(,):“Message.conversation”必须是“conversation”实例。

既然
conva
是由
get\u object\u或\u 404
返回的,并且显然是一个
对话
实例,那么这可能是什么原因

m.conversation = convo,

逗号?

是的,母亲用的是****ing逗号。真不敢相信我错过了。有趣的是,当你专注于某件事时,你竟然会完全错过这样的事情。谢谢。:)