Re: Reusable Chat Application for Django Developers

2019-03-18 Thread panfei
Congratulations !

Ahmed Ishtiaque  于2019年3月19日周二 上午5:44写道:

> Hello everyone,
>
> A couple of months ago I was trying to check if I can use any of the apps
> that appear in Django Packages  Chat
> section but it seems like none of them are maintained very well. So I
> decided to build an open source chat project based on the latest Django
> Channels and WebSocket technologies. The goal of this project is to have a
> chat application that can be easily plugged in to an external parent
> project and would work right out of the box.
>
> The source is here: https://github.com/dibs-devs/chatter
> It's on PyPI as well: https://pypi.org/project/django-chatter/
>
> I would appreciate any feedback/contribution on this project!
>
> Best,
> Ahmed
>
> --
> 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+unsubscr...@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/c3955729-2f8d-431b-988e-e9257bea2c77%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+unsubscr...@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/CA%2BJstLAzoSTG18aB8d_PguFQv1Si4Ce-yb81RD1b2TdZJmQ-Bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Reusable Chat Application for Django Developers

2019-03-18 Thread Aldian Fazrihady
Hi Ahmed,

Congratulations for the open source project.
My website is also using Django Channels for its chatting feature. It is
awesome that you can implement the ideas of a framework that simplifies
websites to have chatting feature.
When I have time, I will check if I can use this module for my website.

On Tue, Mar 19, 2019 at 5:44 AM Ahmed Ishtiaque 
wrote:

> Hello everyone,
>
> A couple of months ago I was trying to check if I can use any of the apps
> that appear in Django Packages  Chat
> section but it seems like none of them are maintained very well. So I
> decided to build an open source chat project based on the latest Django
> Channels and WebSocket technologies. The goal of this project is to have a
> chat application that can be easily plugged in to an external parent
> project and would work right out of the box.
>
> The source is here: https://github.com/dibs-devs/chatter
> It's on PyPI as well: https://pypi.org/project/django-chatter/
>
> I would appreciate any feedback/contribution on this project!
>
> Best,
> Ahmed
>
> --
> 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+unsubscr...@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/c3955729-2f8d-431b-988e-e9257bea2c77%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+unsubscr...@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/CAN7EoAZgs%3D%2BpqrQecjPGscEDZYtJekk-mP2ukt_Z_Mg7VijwDg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Request & Response >> Device send HTTP request to web server

2019-03-18 Thread Mohan Goud
Unit 9 of IoT by Vijay madisetti is completely related to that

On Tue 19 Mar, 2019, 2:43 AM Sabuhi Shukurov  Hello!
>
> I need your help and assistance in my project. Currently we are developing
> project on   the device, which is on arduino written on C low level, it is
> really difficult to handle do many things, we want to keep it as simple as
> we can, everything will rely on to the our web app(Django). device suppose
> to send request in each minute and get response to each request. data comes
> in each minuet as str, we need to parse the data and send response to take
> actions. Is there any example of it?  or anything would help me to work on
> this project? I would definitely appreciate your help. Thanks 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+unsubscr...@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/f38ff183-bcc0-4d45-a5d2-be10633af021%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+unsubscr...@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/CAB29Dkkd5KsasbvNPN%2BjYjyWGb30pb442Yf-CZAw1YDFrxU51A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Reusable Chat Application for Django Developers

2019-03-18 Thread Ahmed Ishtiaque
Hello everyone,

A couple of months ago I was trying to check if I can use any of the apps 
that appear in Django Packages  Chat 
section but it seems like none of them are maintained very well. So I 
decided to build an open source chat project based on the latest Django 
Channels and WebSocket technologies. The goal of this project is to have a 
chat application that can be easily plugged in to an external parent 
project and would work right out of the box. 

The source is here: https://github.com/dibs-devs/chatter
It's on PyPI as well: https://pypi.org/project/django-chatter/

I would appreciate any feedback/contribution on this project! 

Best,
Ahmed

-- 
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+unsubscr...@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/c3955729-2f8d-431b-988e-e9257bea2c77%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Request & Response >> Device send HTTP request to web server

2019-03-18 Thread Sabuhi Shukurov
Hello!

I need your help and assistance in my project. Currently we are developing 
project on   the device, which is on arduino written on C low level, it is 
really difficult to handle do many things, we want to keep it as simple as 
we can, everything will rely on to the our web app(Django). device suppose 
to send request in each minute and get response to each request. data comes 
in each minuet as str, we need to parse the data and send response to take 
actions. Is there any example of it?  or anything would help me to work on 
this project? I would definitely appreciate your help. Thanks 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+unsubscr...@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/f38ff183-bcc0-4d45-a5d2-be10633af021%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Channels - Updating client when the long running celery job finishes

2019-03-18 Thread Suresh Jeevanandam
Thanks a lot. Somehow it did not occur to me that this is the same problem
as a group chat ...

On Mon, Mar 18, 2019 at 7:10 PM Aldian Fazrihady  wrote:

>
> On Mon, Mar 18, 2019 at 9:04 PM Suresh Jeevanandam 
> wrote:
>
>> Can you give some pointers on how you do that? In particular, will the
>> client be notified on the same web socket it established with Django server?
>>
>
> When the JS client established the Web Socket connection, you create a
> channel group for it:
>
> from asgiref.sync import async_to_sync
> from channels.generic.websocket import JsonWebsocketConsumer
>
> class MessageConsumer(JsonWebsocketConsumer):
> def accept(self):
> scope_user = self.scope['user']
>
> async_to_sync(self.channel_layer.group_add)("user-" + 
> scope_user.username, self.channel_name)
> super().accept()
>
>
> Your celery task will do this:
>
> import asyncio
> import json
> import websockets
> from celery import shared_task
> from django.conf import settings
>
> async def async_send_message(
> url, message, to_user, message_type="system.message"
> ):
> async with websockets.connect(url) as websocket:
> payload = {
> "type": message_type, "message": message, "to": {"user": to_user}
> }
> await websocket.send(json.dumps(payload))
>
> @shared_task
> def send_text(text, to_user):
> asyncio.get_event_loop().run_until_complete(
> messaging_utils.async_send_message(
> settings.CHANNEL_MESSAGING_URL, text,username
> )
> )
>
>
> Inside the same MessageConsumer class above, define the methods that
> handles message from celery tasks, to be sent back to JS:
>
> ...
>
> class MessageConsumer(JsonWebsocketConsumer):
> ...
>
> def receive_json(self, content, **kwargs):
>
> async_to_sync(self.channel_layer.group_send)("user-" + 
> content["to"]["user"], content)
>
> def system_message(self, content):
> self.send_json(content)
>
>
> Good Luck!
>
> Aldian Fazrihady
> https://www.aldianfazrihady.com
>
>> --
>> 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+unsubscr...@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/CAExkCEU1ULeqVUShjnQzc%2Bi5rChVRBe9H2m3d0eojQ1_8Lbc7Q%40mail.gmail.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+unsubscr...@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/CAN7EoAYxoQv_5nUo-vVkSPzj05Rn_SB-E5rTOKj0ss-bzvDLqw%40mail.gmail.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+unsubscr...@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/CAExkCEU_oJBL-pcuq97AgyJnZcHv5LO4%3DC-BeEcX_Gx02D9DoQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 2.1.4: Permissions are not updated after migrations

2019-03-18 Thread Yevgeny Bar Lev
Thanks a lot, Simon!
The delete and create sounds like the perfect solution in my case, since I
don't have a lot of permissions assigned.
Will try it now on a test case.

On Mon, Mar 18, 2019 at 3:53 PM Simon Charette  wrote:

> > Would the following strategy work? delete all app permission and use,
> create_permissions to recreate them
>
> Yes, but that will delete all the user and group permissions as well;
> you'll have to reassign them.
>
> > How do I know to which db table a given permission points? Or does it
> point to a model?
>
> They point to models through the Permission.content_type foreign key;
> ContentType have an (app_label, model_name)
> unique tuple.
>
> Best,
> Simon
>
>
>
> Le lundi 18 mars 2019 04:35:55 UTC-4, Yevgeny Bar Lev a écrit :
>>
>> Thanks Simon!
>> Two questions:
>> a) Would the following strategy work? delete all app permission and use,
>> create_permissions to recreate them
>> b) How do I know to which db table a given permission points? Or does it
>> point to a model?
>>
>> On Mon, Mar 18, 2019 at 6:38 AM Simon Charette 
>> wrote:
>>
>>> Hello Yevgeny,
>>>
>>> I'd start by deleting your stale content types[0] which your permissions
>>> are attached
>>> to. That should deal with deleted model case.
>>>
>>> For the renames I suggest you drop into a shell and manually edit the
>>> Permission.name
>>> of the misnamed instances.
>>>
>>> Best,
>>> Simon
>>>
>>> [0]
>>> https://docs.djangoproject.com/en/2.1/ref/django-admin/#django-contrib-contenttypes
>>>
>>> Le dimanche 17 mars 2019 15:52:45 UTC-4, Yevgeny Bar Lev a écrit :

 Thanks Simon. Is there some nonmagical solution? I mean, is it possible
 to fix some of the permissions manually without breaking stuff?

 On Sun, Mar 17, 2019, 9:21 PM Simon Charette 
 wrote:

> Hello Yevgeny,
>
> I don't have magic solution to suggest to you given the current state
> of your
> permission data after a few iterations but I just wanted to let you
> know that
> it's a known issue[0] and a contributor is actively working on getting
> it fixed[1].
>
> Cheers,
> Simon
>
> [0] https://code.djangoproject.com/ticket/29843
> [1] https://github.com/django/django/pull/10540
>
> Le dimanche 17 mars 2019 13:31:16 UTC-4, Yevgeny Bar Lev a écrit :
>>
>> Hello,
>> I have noticed that the available permissions list, which can be set
>> to users/groups in the admin doesn't match my models. This happened 
>> after a
>> few standard migrations, where some models were renamed, some deleted, 
>> and
>> new models were added. The list is basically not updated, and represents 
>> a
>> mixed state of the db, before and after the above migrations.
>>
>> manage.py inspectdb show the CORRECT state of the database.
>>
>> I have tried to follow the following solution, which basically didn't
>> do much.
>>
>> from django.contrib.auth.management import create_permissionsfrom 
>> django.apps import apps
>>
>> create_permissions(apps.get_app_config('my_app_name'))
>>
>> I will appreciate your help.
>> Best,
>> Yevgeny.
>>
> --
> 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/9c49dff1-c6b1-43e6-818d-f56ab761558d%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...@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/7f88aa1a-4d3f-4611-9611-c733b81909a6%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+unsubscr...@googlegroups.com.
> To post to this group, send email to 

Re: Django 2.1.4: Permissions are not updated after migrations

2019-03-18 Thread Simon Charette
> Would the following strategy work? delete all app permission and use, 
create_permissions to recreate them

Yes, but that will delete all the user and group permissions as well; 
you'll have to reassign them.

> How do I know to which db table a given permission points? Or does it 
point to a model?

They point to models through the Permission.content_type foreign key; 
ContentType have an (app_label, model_name)
unique tuple.

Best,
Simon



Le lundi 18 mars 2019 04:35:55 UTC-4, Yevgeny Bar Lev a écrit :
>
> Thanks Simon!
> Two questions:
> a) Would the following strategy work? delete all app permission and use, 
> create_permissions to recreate them
> b) How do I know to which db table a given permission points? Or does it 
> point to a model?
>
> On Mon, Mar 18, 2019 at 6:38 AM Simon Charette  > wrote:
>
>> Hello Yevgeny,
>>
>> I'd start by deleting your stale content types[0] which your permissions 
>> are attached
>> to. That should deal with deleted model case.
>>
>> For the renames I suggest you drop into a shell and manually edit the 
>> Permission.name
>> of the misnamed instances.
>>
>> Best,
>> Simon
>>
>> [0] 
>> https://docs.djangoproject.com/en/2.1/ref/django-admin/#django-contrib-contenttypes
>>
>> Le dimanche 17 mars 2019 15:52:45 UTC-4, Yevgeny Bar Lev a écrit :
>>>
>>> Thanks Simon. Is there some nonmagical solution? I mean, is it possible 
>>> to fix some of the permissions manually without breaking stuff?
>>>
>>> On Sun, Mar 17, 2019, 9:21 PM Simon Charette  wrote:
>>>
 Hello Yevgeny,

 I don't have magic solution to suggest to you given the current state 
 of your
 permission data after a few iterations but I just wanted to let you 
 know that
 it's a known issue[0] and a contributor is actively working on getting 
 it fixed[1].

 Cheers,
 Simon

 [0] https://code.djangoproject.com/ticket/29843
 [1] https://github.com/django/django/pull/10540

 Le dimanche 17 mars 2019 13:31:16 UTC-4, Yevgeny Bar Lev a écrit :
>
> Hello,
> I have noticed that the available permissions list, which can be set 
> to users/groups in the admin doesn't match my models. This happened after 
> a 
> few standard migrations, where some models were renamed, some deleted, 
> and 
> new models were added. The list is basically not updated, and represents 
> a 
> mixed state of the db, before and after the above migrations.
>
> manage.py inspectdb show the CORRECT state of the database. 
>
> I have tried to follow the following solution, which basically didn't 
> do much.
>
> from django.contrib.auth.management import create_permissionsfrom 
> django.apps import apps
>
> create_permissions(apps.get_app_config('my_app_name'))
>
> I will appreciate your help.
> Best,
> Yevgeny.
>
 -- 
 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/9c49dff1-c6b1-43e6-818d-f56ab761558d%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...@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/7f88aa1a-4d3f-4611-9611-c733b81909a6%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+unsubscr...@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/1042f212-68ed-4f3c-b82d-58a50989bb0f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Channels - Updating client when the long running celery job finishes

2019-03-18 Thread Aldian Fazrihady
On Mon, Mar 18, 2019 at 9:04 PM Suresh Jeevanandam 
wrote:

> Can you give some pointers on how you do that? In particular, will the
> client be notified on the same web socket it established with Django server?
>

When the JS client established the Web Socket connection, you create a
channel group for it:

from asgiref.sync import async_to_sync
from channels.generic.websocket import JsonWebsocketConsumer

class MessageConsumer(JsonWebsocketConsumer):
def accept(self):
scope_user = self.scope['user']

async_to_sync(self.channel_layer.group_add)("user-" +
scope_user.username, self.channel_name)
super().accept()


Your celery task will do this:

import asyncio
import json
import websockets
from celery import shared_task
from django.conf import settings

async def async_send_message(
url, message, to_user, message_type="system.message"
):
async with websockets.connect(url) as websocket:
payload = {
"type": message_type, "message": message, "to": {"user": to_user}
}
await websocket.send(json.dumps(payload))

@shared_task
def send_text(text, to_user):
asyncio.get_event_loop().run_until_complete(
messaging_utils.async_send_message(
settings.CHANNEL_MESSAGING_URL, text,username
)
)


Inside the same MessageConsumer class above, define the methods that
handles message from celery tasks, to be sent back to JS:

...

class MessageConsumer(JsonWebsocketConsumer):
...

def receive_json(self, content, **kwargs):

async_to_sync(self.channel_layer.group_send)("user-" +
content["to"]["user"], content)

def system_message(self, content):
self.send_json(content)


Good Luck!

Aldian Fazrihady
https://www.aldianfazrihady.com

> --
> 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+unsubscr...@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/CAExkCEU1ULeqVUShjnQzc%2Bi5rChVRBe9H2m3d0eojQ1_8Lbc7Q%40mail.gmail.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+unsubscr...@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/CAN7EoAYxoQv_5nUo-vVkSPzj05Rn_SB-E5rTOKj0ss-bzvDLqw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Channels - Updating client when the long running celery job finishes

2019-03-18 Thread Suresh Jeevanandam
Can you give some pointers on how you do that? In particular, will the
client be notified on the same web socket it established with Django server?

On Mon, Mar 18, 2019, 6:07 PM Aldian Fazrihady  wrote:

> Hi Suresh,
>
> Yes, celery task can send websocket message to client/JS.
> My celery task uses websockets Python module to contact a Daphne channel
> belongs to JS client.
>
> On Mon, Mar 18, 2019 at 8:28 PM Manas Nikam 
> wrote:
>
>> You can use firebase cloud messaging
>>
>> On Mon, Mar 18, 2019, 5:50 PM Suresh Jeevanandam 
>> wrote:
>>
>>> In my web application based on Django and Channels, the user makes a
>>> web-socket and send a JSON message. This initiates a celery task and a
>>> reference to the task is sent to the user. Now, I want to update the client
>>> when the results are ready.
>>>
>>> The possible solutions I thought were:
>>> 1. The client sends a message through the same WebSocket asking for an
>>> update on the particular task with its ID. The server will reply not-ready
>>> and will send the result once ready.
>>> 2. Use https://github.com/fanout/django-eventstream and make a stream
>>> in a view (/task/ID/update/). This might result in wasting the server-side
>>> resources (because of continuous polling in the view).
>>>
>>> Is there any other better way.
>>>
>>> Is there any background task that we can initiate in the consumer and it
>>> will initiate communitation (send message) when needed. Or better yet, is
>>> there a way we can write to the client's web-socket from the celery task.
>>>
>>> -
>>> Suresh
>>>
>>> --
>>> 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+unsubscr...@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/d6ee181c-8d02-4a51-9215-3da10a75773c%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+unsubscr...@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/CAF%2BYYc5HdBqT5z9ku_PJ-u3Ac6uXBf%2BpTaTxWox1up_rMw%2BVxQ%40mail.gmail.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+unsubscr...@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/CAN7EoAaWMRZ0jb530A1qq763vu%2B2fOf4hKR4MVf%3DQ3XusFUFtg%40mail.gmail.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+unsubscr...@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/CAExkCEU1ULeqVUShjnQzc%2Bi5rChVRBe9H2m3d0eojQ1_8Lbc7Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Channels - Updating client when the long running celery job finishes

2019-03-18 Thread Suresh Jeevanandam
It's a closed network application. So, no access to firebase.

On Mon, Mar 18, 2019, 5:58 PM Manas Nikam  wrote:

> You can use firebase cloud messaging
>
> On Mon, Mar 18, 2019, 5:50 PM Suresh Jeevanandam 
> wrote:
>
>> In my web application based on Django and Channels, the user makes a
>> web-socket and send a JSON message. This initiates a celery task and a
>> reference to the task is sent to the user. Now, I want to update the client
>> when the results are ready.
>>
>> The possible solutions I thought were:
>> 1. The client sends a message through the same WebSocket asking for an
>> update on the particular task with its ID. The server will reply not-ready
>> and will send the result once ready.
>> 2. Use https://github.com/fanout/django-eventstream and make a stream in
>> a view (/task/ID/update/). This might result in wasting the server-side
>> resources (because of continuous polling in the view).
>>
>> Is there any other better way.
>>
>> Is there any background task that we can initiate in the consumer and it
>> will initiate communitation (send message) when needed. Or better yet, is
>> there a way we can write to the client's web-socket from the celery task.
>>
>> -
>> Suresh
>>
>> --
>> 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+unsubscr...@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/d6ee181c-8d02-4a51-9215-3da10a75773c%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+unsubscr...@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/CAF%2BYYc5HdBqT5z9ku_PJ-u3Ac6uXBf%2BpTaTxWox1up_rMw%2BVxQ%40mail.gmail.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+unsubscr...@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/CAExkCEWr1a2YDBCHYSWWCxoJDDGh5-8a6K5KoirqOu6Z5WXsSg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Channels - Updating client when the long running celery job finishes

2019-03-18 Thread Aldian Fazrihady
Hi Suresh,

Yes, celery task can send websocket message to client/JS.
My celery task uses websockets Python module to contact a Daphne channel
belongs to JS client.

On Mon, Mar 18, 2019 at 8:28 PM Manas Nikam  wrote:

> You can use firebase cloud messaging
>
> On Mon, Mar 18, 2019, 5:50 PM Suresh Jeevanandam 
> wrote:
>
>> In my web application based on Django and Channels, the user makes a
>> web-socket and send a JSON message. This initiates a celery task and a
>> reference to the task is sent to the user. Now, I want to update the client
>> when the results are ready.
>>
>> The possible solutions I thought were:
>> 1. The client sends a message through the same WebSocket asking for an
>> update on the particular task with its ID. The server will reply not-ready
>> and will send the result once ready.
>> 2. Use https://github.com/fanout/django-eventstream and make a stream in
>> a view (/task/ID/update/). This might result in wasting the server-side
>> resources (because of continuous polling in the view).
>>
>> Is there any other better way.
>>
>> Is there any background task that we can initiate in the consumer and it
>> will initiate communitation (send message) when needed. Or better yet, is
>> there a way we can write to the client's web-socket from the celery task.
>>
>> -
>> Suresh
>>
>> --
>> 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+unsubscr...@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/d6ee181c-8d02-4a51-9215-3da10a75773c%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+unsubscr...@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/CAF%2BYYc5HdBqT5z9ku_PJ-u3Ac6uXBf%2BpTaTxWox1up_rMw%2BVxQ%40mail.gmail.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+unsubscr...@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/CAN7EoAaWMRZ0jb530A1qq763vu%2B2fOf4hKR4MVf%3DQ3XusFUFtg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Channels - Updating client when the long running celery job finishes

2019-03-18 Thread Manas Nikam
You can use firebase cloud messaging

On Mon, Mar 18, 2019, 5:50 PM Suresh Jeevanandam 
wrote:

> In my web application based on Django and Channels, the user makes a
> web-socket and send a JSON message. This initiates a celery task and a
> reference to the task is sent to the user. Now, I want to update the client
> when the results are ready.
>
> The possible solutions I thought were:
> 1. The client sends a message through the same WebSocket asking for an
> update on the particular task with its ID. The server will reply not-ready
> and will send the result once ready.
> 2. Use https://github.com/fanout/django-eventstream and make a stream in
> a view (/task/ID/update/). This might result in wasting the server-side
> resources (because of continuous polling in the view).
>
> Is there any other better way.
>
> Is there any background task that we can initiate in the consumer and it
> will initiate communitation (send message) when needed. Or better yet, is
> there a way we can write to the client's web-socket from the celery task.
>
> -
> Suresh
>
> --
> 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+unsubscr...@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/d6ee181c-8d02-4a51-9215-3da10a75773c%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+unsubscr...@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/CAF%2BYYc5HdBqT5z9ku_PJ-u3Ac6uXBf%2BpTaTxWox1up_rMw%2BVxQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: test if model object fits into QuerySet without executing SQL?

2019-03-18 Thread jgibson
result = qs1.difference(qs2)

if Result is length 0 then all of 1 is in 2.

On Monday, March 18, 2019 at 8:15:19 AM UTC-4, Thomas Klopf wrote:
>
> Hello,
>   Yes exactly that, if mo1 is in qs2. BUT without running the SQL on the 
> database, if possible.
>
> Thanks!
> Tom
>
>
> On Friday, March 15, 2019 at 1:34:34 PM UTC+1, jgi...@caktusgroup.com 
> wrote:
>>
>> Tom,
>>
>> Could you clarify "fits into"?
>>
>> qs1 = Table.objects.all()
>> qs2 = Table.objects.filter(color='blue')
>>
>>
>> mo1 = qs1[0]
>>
>>
>> Are you trying to determine if mo1 is in qs2?
>>
>> Best
>>
>> On Friday, March 15, 2019 at 7:46:14 AM UTC-4, Thomas Klopf wrote:
>>>
>>> Hi all,
>>>   Please I have a question, couldn't find any answer for it..
>>>
>>>   Let's say I have 2 QuerySets:
>>>   1) Select all records from table
>>>   2) Select all records from table where color = "blue"
>>>
>>> So QuerySet #2 is more restricted than QuerySet #1
>>>
>>> So question is - if I get a model object from QuerySet #1, is it 
>>> possible to check if the model object is 'filtered'  or fits into QuerySet 
>>> #2, without actually executing the SQL for QuerySet #2 to find the record 
>>> again?
>>>
>>> I'm asking because running the SQL for QuerySet #2 is expensive, ideally 
>>> would test if the record fits into the QuerySet in purely python/django.
>>>
>>> Thanks in advance!
>>> Tom
>>>
>>>

-- 
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+unsubscr...@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/c5314fff-37cf-4763-9ab8-2c055add3901%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: test if model object fits into QuerySet without executing SQL?

2019-03-18 Thread Jani Tiainen
Hi,

Note that Django querysets are lazy.

So running:

qs1 = MyModel.objects.all()

As is, doing that doesn't execute any queries. If you want filtered
objects, just add filter:

qs2 = qs1.filter(color="blue")

qs2 is not even evaluated yet. You need actually cause something that
evaluates queryset.

But if you want to fetch all objects from qs1 and then apply some
"filtering" you can just evaluate whole queryset and it's results
will be cached. You can use list comprehensions or itertools to filter your
objects in Python.


On Mon, Mar 18, 2019 at 2:16 PM Thomas Klopf  wrote:

> Hello,
>   Yes exactly that, if mo1 is in qs2. BUT without running the SQL on the
> database, if possible.
>
> Thanks!
> Tom
>
>
> On Friday, March 15, 2019 at 1:34:34 PM UTC+1, jgi...@caktusgroup.com
> wrote:
>>
>> Tom,
>>
>> Could you clarify "fits into"?
>>
>> qs1 = Table.objects.all()
>> qs2 = Table.objects.filter(color='blue')
>>
>>
>> mo1 = qs1[0]
>>
>>
>> Are you trying to determine if mo1 is in qs2?
>>
>> Best
>>
>> On Friday, March 15, 2019 at 7:46:14 AM UTC-4, Thomas Klopf wrote:
>>>
>>> Hi all,
>>>   Please I have a question, couldn't find any answer for it..
>>>
>>>   Let's say I have 2 QuerySets:
>>>   1) Select all records from table
>>>   2) Select all records from table where color = "blue"
>>>
>>> So QuerySet #2 is more restricted than QuerySet #1
>>>
>>> So question is - if I get a model object from QuerySet #1, is it
>>> possible to check if the model object is 'filtered'  or fits into QuerySet
>>> #2, without actually executing the SQL for QuerySet #2 to find the record
>>> again?
>>>
>>> I'm asking because running the SQL for QuerySet #2 is expensive, ideally
>>> would test if the record fits into the QuerySet in purely python/django.
>>>
>>> Thanks in advance!
>>> Tom
>>>
>>> --
> 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+unsubscr...@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/a09cf16e-8f9c-4bf0-b382-708ba21d28bd%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Jani Tiainen
Software wizard

https://blog.jani.tiainen.cc/

Always open for short term jobs or contracts to work with Django.

-- 
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+unsubscr...@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/CAHn91oeVhEmC2kGeGmHYjRcq1KJJvhxwbUBEyHv8zdriHDF1eQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Channels - Updating client when the long running celery job finishes

2019-03-18 Thread Suresh Jeevanandam
In my web application based on Django and Channels, the user makes a 
web-socket and send a JSON message. This initiates a celery task and a 
reference to the task is sent to the user. Now, I want to update the client 
when the results are ready.

The possible solutions I thought were:
1. The client sends a message through the same WebSocket asking for an 
update on the particular task with its ID. The server will reply not-ready 
and will send the result once ready.
2. Use https://github.com/fanout/django-eventstream and make a stream in a 
view (/task/ID/update/). This might result in wasting the server-side 
resources (because of continuous polling in the view).

Is there any other better way.

Is there any background task that we can initiate in the consumer and it 
will initiate communitation (send message) when needed. Or better yet, is 
there a way we can write to the client's web-socket from the celery task.

-
Suresh

-- 
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+unsubscr...@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/d6ee181c-8d02-4a51-9215-3da10a75773c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: test if model object fits into QuerySet without executing SQL?

2019-03-18 Thread Thomas Klopf
Hello,
  Yes exactly that, if mo1 is in qs2. BUT without running the SQL on the 
database, if possible.

Thanks!
Tom


On Friday, March 15, 2019 at 1:34:34 PM UTC+1, jgi...@caktusgroup.com wrote:
>
> Tom,
>
> Could you clarify "fits into"?
>
> qs1 = Table.objects.all()
> qs2 = Table.objects.filter(color='blue')
>
>
> mo1 = qs1[0]
>
>
> Are you trying to determine if mo1 is in qs2?
>
> Best
>
> On Friday, March 15, 2019 at 7:46:14 AM UTC-4, Thomas Klopf wrote:
>>
>> Hi all,
>>   Please I have a question, couldn't find any answer for it..
>>
>>   Let's say I have 2 QuerySets:
>>   1) Select all records from table
>>   2) Select all records from table where color = "blue"
>>
>> So QuerySet #2 is more restricted than QuerySet #1
>>
>> So question is - if I get a model object from QuerySet #1, is it possible 
>> to check if the model object is 'filtered'  or fits into QuerySet #2, 
>> without actually executing the SQL for QuerySet #2 to find the record again?
>>
>> I'm asking because running the SQL for QuerySet #2 is expensive, ideally 
>> would test if the record fits into the QuerySet in purely python/django.
>>
>> Thanks in advance!
>> Tom
>>
>>

-- 
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+unsubscr...@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/a09cf16e-8f9c-4bf0-b382-708ba21d28bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django 2.2 release candidate 1 released

2019-03-18 Thread Carlton Gibson
We've made the final (hopefully) release on the way to Django's next 
major release, Django 2.2! Check out the blog post: 
https://www.djangoproject.com/weblog/2019/mar/18/django-22-rc1/

-- 
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+unsubscr...@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/0606040C-D01D-4BFD-956C-2663DCAE7BF2%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 2.1.4: Permissions are not updated after migrations

2019-03-18 Thread Yevgeny Bar Lev
Thanks Simon!
Two questions:
a) Would the following strategy work? delete all app permission and use,
create_permissions to recreate them
b) How do I know to which db table a given permission points? Or does it
point to a model?

On Mon, Mar 18, 2019 at 6:38 AM Simon Charette  wrote:

> Hello Yevgeny,
>
> I'd start by deleting your stale content types[0] which your permissions
> are attached
> to. That should deal with deleted model case.
>
> For the renames I suggest you drop into a shell and manually edit the
> Permission.name
> of the misnamed instances.
>
> Best,
> Simon
>
> [0]
> https://docs.djangoproject.com/en/2.1/ref/django-admin/#django-contrib-contenttypes
>
> Le dimanche 17 mars 2019 15:52:45 UTC-4, Yevgeny Bar Lev a écrit :
>>
>> Thanks Simon. Is there some nonmagical solution? I mean, is it possible
>> to fix some of the permissions manually without breaking stuff?
>>
>> On Sun, Mar 17, 2019, 9:21 PM Simon Charette  wrote:
>>
>>> Hello Yevgeny,
>>>
>>> I don't have magic solution to suggest to you given the current state of
>>> your
>>> permission data after a few iterations but I just wanted to let you know
>>> that
>>> it's a known issue[0] and a contributor is actively working on getting
>>> it fixed[1].
>>>
>>> Cheers,
>>> Simon
>>>
>>> [0] https://code.djangoproject.com/ticket/29843
>>> [1] https://github.com/django/django/pull/10540
>>>
>>> Le dimanche 17 mars 2019 13:31:16 UTC-4, Yevgeny Bar Lev a écrit :

 Hello,
 I have noticed that the available permissions list, which can be set to
 users/groups in the admin doesn't match my models. This happened after a
 few standard migrations, where some models were renamed, some deleted, and
 new models were added. The list is basically not updated, and represents a
 mixed state of the db, before and after the above migrations.

 manage.py inspectdb show the CORRECT state of the database.

 I have tried to follow the following solution, which basically didn't
 do much.

 from django.contrib.auth.management import create_permissionsfrom 
 django.apps import apps

 create_permissions(apps.get_app_config('my_app_name'))

 I will appreciate your help.
 Best,
 Yevgeny.

>>> --
>>> 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/9c49dff1-c6b1-43e6-818d-f56ab761558d%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+unsubscr...@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/7f88aa1a-4d3f-4611-9611-c733b81909a6%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+unsubscr...@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/CAEBarV2WrmtbUwtf9Ljkfp-PJv93KSC7eiMcF10Jb2Js0OuNhw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.