You should just get the room object attribute you need, like name or id, instead of concatenating the whole object
On Apr 27, 2017 5:26 AM, "Yarnball" <yconomos@gmail.com> wrote:
I do appreciate the bit of direction youve provided. And if you're asking to be paid, then sorry but I'm working free on a community project so it isn't such an option. Also why it would be good to get help on this minor task.--I'm almost there :)I took your advice and put it in a loop. I am seeing the result, but getting a `TypeError: <Room: super> is not JSON serializable`
@channel_session
def ws_connect(message):
room_id = Tag.objects.filter(owner=1).filter (chat__isnull=False).values ('chat__label').distinct()
print('I see values here', room_id)
for i in room_id:
try:
room = Room.objects.get(label=i['chat__label' ])
chathistory = room.messages.all().order_by('timestamp' )
Group('chat-' ).add(message.reply_channel)
message.channel_session['room'] = room
message.reply_channel.send({'text' : json.dumps([msg.as_dict() for msg in chathistory.all()])})
except Exception as e:
print (str(e), ' Never happened')
pass
@channel_session
def ws_receive(message):
label = message.channel_session['room']
room = Room.objects.get(label=label)
data = json.loads(message['text'])
m = room.messages.create(handle=data ['handle'], message=data['message'])
Group('chat-'+label).send({'text' : json.dumps([m.as_dict()])})
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 django-users+unsubscribe@googlegroups.com .
To post to this group, send email to django-users@googlegroups.com.
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/5453a756- .2e87-47be-8e81-4359e200d0db% 40googlegroups.com
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CAFWa6t%2BBqX522gYNQoYNRM8jgFbuR%2Bbs_GFdKA3UpTfsRQJ-Zg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment