Thursday, January 19, 2017

Re: Django-channels save reply channel to django model field?

So for example when I need the reply channel in the ws recieve method I need to create the Channel again and it will be the same channel referring to the same user? And do I have to delete the newly created channel after each ws recieve method?

четвъртък, 19 януари 2017 г., 20:25:41 UTC+2, Andrew Godwin написа:
Hi,

Channel isn't a field type - it's a separate datastructure entirely from a database/Django models and is powered by its own code and servers (the channel layer).

If you want to persist the name of a reply_channel for use later, like knowing what channel connections are on to send information down, then use a CharField(max_length=255), and put the name of the channel in that (which is usually reply_channel.name). You can then take the string name and pass it to channel to make it again like Channel(reply_channel_name).

Hope that helps,
Andrew

On Thu, Jan 19, 2017 at 6:57 AM, Nikoleta Misheva <nith...@gmail.com> wrote:
Hello, sorry to bother you but how do you make a django-channels  Channel field in a Django model? I tried to use ForeignKey and ForeignObject but doesn't do the work.
Thank you in advance :)

--
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...@googlegroups.com.
To post to this group, send email to django...@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/ace270a5-ccba-43b2-aa54-bc425de9f709%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/b1626db4-9818-4c77-bc31-48ce5d9a6d0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment