Re: Django Channels 2.0.0 groups

2018-02-02 Thread Andrew Godwin
Ah, yes, it looks like aioredis requires at least 3.5.2. I will update the
channels_redis readme to make this clear.

On Fri, Feb 2, 2018 at 11:44 PM, Ahmed Magdy  wrote:

> v3.5.1:37a07cee5969
>
> On Saturday, February 3, 2018 at 9:41:38 AM UTC+2, Andrew Godwin wrote:
>>
>> That looks like a problem with the version of Python you are running -
>> what version is it?
>>
>> Andrew
>>
>> On Fri, Feb 2, 2018 at 11:36 PM, Ahmed Magdy  wrote:
>>
>>> Since you closed the issue, I'm posting here.
>>> Ok, so I've updated asgiref package to 2.1.1 and now getting different
>>> exception.
>>>
>>>
>>> [2018/02/03 09:29:23] WebSocket HANDSHAKING /sessions/ [127.0.0.1:13235]
 ERROR:root:Exception inside application: '_WindowsSelectorEventLoop'
 object has no attribute 'create_future'
   File "c:\python35\Lib\asyncio\tasks.py", line 241, in _step
 result = coro.throw(exc)
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\consumer.py",
 line 51, in __call__
 await await_many_dispatch([receive, self.channel_receive],
 self.dispatch)
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\utils.py",
 line 48, in await_many_dispatch
 await dispatch(result)
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
 line 99, in inner
 return await async_func(*args, **kwargs)
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
 line 79, in __call__
 return await asyncio.wait_for(future, timeout=None)
   File "c:\python35\Lib\asyncio\tasks.py", line 367, in wait_for
 return (yield from fut)
   File "c:\python35\Lib\asyncio\futures.py", line 358, in __iter__
 yield self  # This tells Task to wait for completion.
   File "c:\python35\Lib\asyncio\tasks.py", line 290, in _wakeup
 future.result()
   File "c:\python35\Lib\asyncio\futures.py", line 274, in result
 raise self._exception
   File "c:\python35\Lib\concurrent\futures\thread.py", line 55, in run
 result = self.fn(*self.args, **self.kwargs)
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
 line 91, in thread_handler
 raise e
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
 line 89, in thread_handler
 self.func(*args, **kwargs)
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\consumer.py",
 line 93, in dispatch
 handler(message)
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\generic\websocket.py",
 line 19, in websocket_connect
 self.connect()
   File "D:\Programming\DjangoWebsite\HUWebsite\husite\djangoChannel
 s\djangoChannels\consumers.py", line 7, in connect
 AsyncToSync(self.channel_layer.group_add)("chat",
 self.channel_name)
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
 line 45, in __call__
 call_result.result()
   File "c:\python35\Lib\concurrent\futures\_base.py", line 405, in
 result
 return self.__get_result()
   File "c:\python35\Lib\concurrent\futures\_base.py", line 357, in
 __get_result
 raise self._exception
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
 line 53, in main_wrap
 result = await self.awaitable(*args, **kwargs)
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels_redis\core.py",
 line 280, in group_add
 pool = await self.connection(self.consistent_hash(group))
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels_redis\core.py",
 line 377, in connection
 self.pools[index] = await aioredis.create_redis_pool(**s
 elf.hosts[index])
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\aioredis\commands\__init__.py",
 line 197, in create_redis_pool
 loop=loop)
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\aioredis\pool.py",
 line 56, in create_pool
 await pool._fill_free(override_min=False)
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\aioredis\pool.py",
 line 388, in _fill_free
 conn = await self._create_new_connection(address)
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\aioredis\connection.py",
 line 124, in create_connection
 loop=loop)
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\aioredis\connection.py",
 line 163, in __init__
 self._close_waiter = loop.create_future()
   '_WindowsSelectorEventLoop' object has no attribute 'create_future'
 [2018/02/03 09:29:24] WebSocket DISCONNECT /sessions/ [127.0.0.1:

Re: Django Channels 2.0.0 groups

2018-02-02 Thread Ahmed Magdy
v3.5.1:37a07cee5969

On Saturday, February 3, 2018 at 9:41:38 AM UTC+2, Andrew Godwin wrote:
>
> That looks like a problem with the version of Python you are running - 
> what version is it?
>
> Andrew
>
> On Fri, Feb 2, 2018 at 11:36 PM, Ahmed Magdy  > wrote:
>
>> Since you closed the issue, I'm posting here.
>> Ok, so I've updated asgiref package to 2.1.1 and now getting different 
>> exception.
>>
>>
>> [2018/02/03 09:29:23] WebSocket HANDSHAKING /sessions/ [127.0.0.1:13235]
>>> ERROR:root:Exception inside application: '_WindowsSelectorEventLoop' 
>>> object has no attribute 'create_future'
>>>   File "c:\python35\Lib\asyncio\tasks.py", line 241, in _step
>>> result = coro.throw(exc)
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\consumer.py",
>>>  
>>> line 51, in __call__
>>> await await_many_dispatch([receive, self.channel_receive], 
>>> self.dispatch)
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\utils.py",
>>>  
>>> line 48, in await_many_dispatch
>>> await dispatch(result)
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py", 
>>> line 99, in inner
>>> return await async_func(*args, **kwargs)
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py", 
>>> line 79, in __call__
>>> return await asyncio.wait_for(future, timeout=None)
>>>   File "c:\python35\Lib\asyncio\tasks.py", line 367, in wait_for
>>> return (yield from fut)
>>>   File "c:\python35\Lib\asyncio\futures.py", line 358, in __iter__
>>> yield self  # This tells Task to wait for completion.
>>>   File "c:\python35\Lib\asyncio\tasks.py", line 290, in _wakeup
>>> future.result()
>>>   File "c:\python35\Lib\asyncio\futures.py", line 274, in result
>>> raise self._exception
>>>   File "c:\python35\Lib\concurrent\futures\thread.py", line 55, in run
>>> result = self.fn(*self.args, **self.kwargs)
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py", 
>>> line 91, in thread_handler
>>> raise e
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py", 
>>> line 89, in thread_handler
>>> self.func(*args, **kwargs)
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\consumer.py",
>>>  
>>> line 93, in dispatch
>>> handler(message)
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\generic\websocket.py",
>>>  
>>> line 19, in websocket_connect
>>> self.connect()
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\husite\djangoChannels\djangoChannels\consumers.py",
>>>  
>>> line 7, in connect
>>> AsyncToSync(self.channel_layer.group_add)("chat", self.channel_name)
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py", 
>>> line 45, in __call__
>>> call_result.result()
>>>   File "c:\python35\Lib\concurrent\futures\_base.py", line 405, in result
>>> return self.__get_result()
>>>   File "c:\python35\Lib\concurrent\futures\_base.py", line 357, in 
>>> __get_result
>>> raise self._exception
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py", 
>>> line 53, in main_wrap
>>> result = await self.awaitable(*args, **kwargs)
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels_redis\core.py",
>>>  
>>> line 280, in group_add
>>> pool = await self.connection(self.consistent_hash(group))
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels_redis\core.py",
>>>  
>>> line 377, in connection
>>> self.pools[index] = await 
>>> aioredis.create_redis_pool(**self.hosts[index])
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\aioredis\commands\__init__.py",
>>>  
>>> line 197, in create_redis_pool
>>> loop=loop)
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\aioredis\pool.py",
>>>  
>>> line 56, in create_pool
>>> await pool._fill_free(override_min=False)
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\aioredis\pool.py",
>>>  
>>> line 388, in _fill_free
>>> conn = await self._create_new_connection(address)
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\aioredis\connection.py",
>>>  
>>> line 124, in create_connection
>>> loop=loop)
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\aioredis\connection.py",
>>>  
>>> line 163, in __init__
>>> self._close_waiter = loop.create_future()
>>>   '_WindowsSelectorEventLoop' object has no attribute 'create_future'
>>> [2018/02/03 09:29:24] WebSocket DISCONNECT /sessions/ [127.0.0.1:13235]
>>> [2018/02/03 09:30:24] HTTP GET /sessions/ 503 [60.64, 127.0.0.1:13235]
>>> ERROR:asyncio:Task exception was never retrieved
>>> future: >> D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages

Re: Django Channels 2.0.0 groups

2018-02-02 Thread Andrew Godwin
That looks like a problem with the version of Python you are running - what
version is it?

Andrew

On Fri, Feb 2, 2018 at 11:36 PM, Ahmed Magdy  wrote:

> Since you closed the issue, I'm posting here.
> Ok, so I've updated asgiref package to 2.1.1 and now getting different
> exception.
>
>
> [2018/02/03 09:29:23] WebSocket HANDSHAKING /sessions/ [127.0.0.1:13235]
>> ERROR:root:Exception inside application: '_WindowsSelectorEventLoop'
>> object has no attribute 'create_future'
>>   File "c:\python35\Lib\asyncio\tasks.py", line 241, in _step
>> result = coro.throw(exc)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\consumer.py",
>> line 51, in __call__
>> await await_many_dispatch([receive, self.channel_receive],
>> self.dispatch)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\utils.py",
>> line 48, in await_many_dispatch
>> await dispatch(result)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
>> line 99, in inner
>> return await async_func(*args, **kwargs)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
>> line 79, in __call__
>> return await asyncio.wait_for(future, timeout=None)
>>   File "c:\python35\Lib\asyncio\tasks.py", line 367, in wait_for
>> return (yield from fut)
>>   File "c:\python35\Lib\asyncio\futures.py", line 358, in __iter__
>> yield self  # This tells Task to wait for completion.
>>   File "c:\python35\Lib\asyncio\tasks.py", line 290, in _wakeup
>> future.result()
>>   File "c:\python35\Lib\asyncio\futures.py", line 274, in result
>> raise self._exception
>>   File "c:\python35\Lib\concurrent\futures\thread.py", line 55, in run
>> result = self.fn(*self.args, **self.kwargs)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
>> line 91, in thread_handler
>> raise e
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
>> line 89, in thread_handler
>> self.func(*args, **kwargs)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\consumer.py",
>> line 93, in dispatch
>> handler(message)
>>   File "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\
>> channels\generic\websocket.py", line 19, in websocket_connect
>> self.connect()
>>   File "D:\Programming\DjangoWebsite\HUWebsite\husite\
>> djangoChannels\djangoChannels\consumers.py", line 7, in connect
>> AsyncToSync(self.channel_layer.group_add)("chat", self.channel_name)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
>> line 45, in __call__
>> call_result.result()
>>   File "c:\python35\Lib\concurrent\futures\_base.py", line 405, in result
>> return self.__get_result()
>>   File "c:\python35\Lib\concurrent\futures\_base.py", line 357, in
>> __get_result
>> raise self._exception
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
>> line 53, in main_wrap
>> result = await self.awaitable(*args, **kwargs)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels_redis\core.py",
>> line 280, in group_add
>> pool = await self.connection(self.consistent_hash(group))
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels_redis\core.py",
>> line 377, in connection
>> self.pools[index] = await aioredis.create_redis_pool(**
>> self.hosts[index])
>>   File "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\
>> aioredis\commands\__init__.py", line 197, in create_redis_pool
>> loop=loop)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\aioredis\pool.py",
>> line 56, in create_pool
>> await pool._fill_free(override_min=False)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\aioredis\pool.py",
>> line 388, in _fill_free
>> conn = await self._create_new_connection(address)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\aioredis\connection.py",
>> line 124, in create_connection
>> loop=loop)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\aioredis\connection.py",
>> line 163, in __init__
>> self._close_waiter = loop.create_future()
>>   '_WindowsSelectorEventLoop' object has no attribute 'create_future'
>> [2018/02/03 09:29:24] WebSocket DISCONNECT /sessions/ [127.0.0.1:13235]
>> [2018/02/03 09:30:24] HTTP GET /sessions/ 503 [60.64, 127.0.0.1:13235]
>> ERROR:asyncio:Task exception was never retrieved
>> future: > D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels_redis\core.py:137>
>> exception=AttributeError("'_WindowsSelectorEventLoop'
>> object has no attribute 'create_future'",)>
>> Traceback (most recent call last):
>>   File "c:\python35\Lib\asyncio\tasks.py", line 239, in _step
>> result = coro.send(None)
>>   File 
>> "D:\Programming\DjangoW

Re: Django Channels 2.0.0 groups

2018-02-02 Thread Ahmed Magdy
Since you closed the issue, I'm posting here.
Ok, so I've updated asgiref package to 2.1.1 and now getting different 
exception.


[2018/02/03 09:29:23] WebSocket HANDSHAKING /sessions/ [127.0.0.1:13235]
> ERROR:root:Exception inside application: '_WindowsSelectorEventLoop' 
> object has no attribute 'create_future'
>   File "c:\python35\Lib\asyncio\tasks.py", line 241, in _step
> result = coro.throw(exc)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\consumer.py",
>  
> line 51, in __call__
> await await_many_dispatch([receive, self.channel_receive], 
> self.dispatch)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\utils.py", 
> line 48, in await_many_dispatch
> await dispatch(result)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py", 
> line 99, in inner
> return await async_func(*args, **kwargs)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py", 
> line 79, in __call__
> return await asyncio.wait_for(future, timeout=None)
>   File "c:\python35\Lib\asyncio\tasks.py", line 367, in wait_for
> return (yield from fut)
>   File "c:\python35\Lib\asyncio\futures.py", line 358, in __iter__
> yield self  # This tells Task to wait for completion.
>   File "c:\python35\Lib\asyncio\tasks.py", line 290, in _wakeup
> future.result()
>   File "c:\python35\Lib\asyncio\futures.py", line 274, in result
> raise self._exception
>   File "c:\python35\Lib\concurrent\futures\thread.py", line 55, in run
> result = self.fn(*self.args, **self.kwargs)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py", 
> line 91, in thread_handler
> raise e
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py", 
> line 89, in thread_handler
> self.func(*args, **kwargs)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\consumer.py",
>  
> line 93, in dispatch
> handler(message)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\generic\websocket.py",
>  
> line 19, in websocket_connect
> self.connect()
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\husite\djangoChannels\djangoChannels\consumers.py",
>  
> line 7, in connect
> AsyncToSync(self.channel_layer.group_add)("chat", self.channel_name)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py", 
> line 45, in __call__
> call_result.result()
>   File "c:\python35\Lib\concurrent\futures\_base.py", line 405, in result
> return self.__get_result()
>   File "c:\python35\Lib\concurrent\futures\_base.py", line 357, in 
> __get_result
> raise self._exception
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py", 
> line 53, in main_wrap
> result = await self.awaitable(*args, **kwargs)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels_redis\core.py",
>  
> line 280, in group_add
> pool = await self.connection(self.consistent_hash(group))
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels_redis\core.py",
>  
> line 377, in connection
> self.pools[index] = await 
> aioredis.create_redis_pool(**self.hosts[index])
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\aioredis\commands\__init__.py",
>  
> line 197, in create_redis_pool
> loop=loop)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\aioredis\pool.py", 
> line 56, in create_pool
> await pool._fill_free(override_min=False)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\aioredis\pool.py", 
> line 388, in _fill_free
> conn = await self._create_new_connection(address)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\aioredis\connection.py",
>  
> line 124, in create_connection
> loop=loop)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\aioredis\connection.py",
>  
> line 163, in __init__
> self._close_waiter = loop.create_future()
>   '_WindowsSelectorEventLoop' object has no attribute 'create_future'
> [2018/02/03 09:29:24] WebSocket DISCONNECT /sessions/ [127.0.0.1:13235]
> [2018/02/03 09:30:24] HTTP GET /sessions/ 503 [60.64, 127.0.0.1:13235]
> ERROR:asyncio:Task exception was never retrieved
> future:  D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels_redis\core.py:137>
>  
> exception=AttributeError("'_WindowsSelectorEventLoop'
> object has no attribute 'create_future'",)>
> Traceback (most recent call last):
>   File "c:\python35\Lib\asyncio\tasks.py", line 239, in _step
> result = coro.send(None)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels_redis\core.py",
>  
> line 158, in receive
> return await self.receive_buffer_lpop(channel)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-package

Re: Django Channels 2.0.0 groups

2018-02-02 Thread Andrew Godwin
Yup, that looks like a genuine bug, I have opened a GitHub issue to track
it: https://github.com/django/channels/issues/848

Andrew

On Fri, Feb 2, 2018 at 10:35 PM, Ahmed Magdy  wrote:

> I even made sure to read the docs multiple times before posting. :/
>
> I've been reading about Redis, and since I got windows OS, I installed the
> port for Windows based redis ,
> tested the server and client they are working ok
> .
>
> # settings.py
> # ...
> ASGI_APPLICATION = 'djangoChannels.routing.application'
>
> CHANNEL_LAYERS = {
>"default": {
>"BACKEND": "channels_redis.core.RedisChannelLayer",
>"CONFIG": {
>"hosts": [("localhost", 6379)],
>},
>},
> }
>
>
> # consumers.py
> from asgiref.sync import AsyncToSync
> from channels.generic.websocket import WebsocketConsumer
>
> class ChatConsumer(WebsocketConsumer):
>def connect(self):
>AsyncToSync(self.channel_layer.group_add)("chat", self
> .channel_name)
>
> def disconnect(self):
>AsyncToSync(self.channel_layer.group_discard)("chat", self
> .channel_name)
>
> raises an exception
>
> [2018/02/03 08:30:19] WebSocket HANDSHAKING /sessions/ [127.0.0.1:12778]
>> ERROR:root:Exception inside application: There is no current event loop
>> in thread 'Thread-3'.
>>   File "c:\python35\Lib\asyncio\tasks.py", line 241, in _step
>> result = coro.throw(exc)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\consumer.py",
>> line 51, in __call__
>> await await_many_dispatch([receive, self.channel_receive],
>> self.dispatch)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\utils.py",
>> line 48, in await_many_dispatch
>> await dispatch(result)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
>> line 84, in inner
>> return await async_func(*args, **kwargs)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
>> line 67, in __call__
>> return await asyncio.wait_for(future, timeout=None)
>>   File "c:\python35\Lib\asyncio\tasks.py", line 367, in wait_for
>> return (yield from fut)
>>   File "c:\python35\Lib\asyncio\futures.py", line 358, in __iter__
>> yield self  # This tells Task to wait for completion.
>>   File "c:\python35\Lib\asyncio\tasks.py", line 290, in _wakeup
>> future.result()
>>   File "c:\python35\Lib\asyncio\futures.py", line 274, in result
>> raise self._exception
>>   File "c:\python35\Lib\concurrent\futures\thread.py", line 55, in run
>> result = self.fn(*self.args, **self.kwargs)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
>> line 76, in thread_handler
>> raise e
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
>> line 74, in thread_handler
>> self.func(*args, **kwargs)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\consumer.py",
>> line 93, in dispatch
>> handler(message)
>>   File "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\
>> channels\generic\websocket.py", line 19, in websocket_connect
>> self.connect()
>>   File "D:\Programming\DjangoWebsite\HUWebsite\husite\
>> djangoChannels\djangoChannels\consumers.py", line 7, in connect
>> AsyncToSync(self.channel_layer.group_add)("chat", self.channel_name)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
>> line 17, in __init__
>> self.main_event_loop = asyncio.get_event_loop()
>>   File "c:\python35\Lib\asyncio\events.py", line 626, in get_event_loop
>> return get_event_loop_policy().get_event_loop()
>>   File "c:\python35\Lib\asyncio\events.py", line 572, in get_event_loop
>> % threading.current_thread().name)
>>   There is no current event loop in thread 'Thread-3'.
>>
>
> Thanks for what you did so far!
>
> On Saturday, February 3, 2018 at 6:58:56 AM UTC+2, Andrew Godwin wrote:
>>
>> The docs do mention this in a big callout at the top of the Channel
>> Layers page :) http://channels.readthedocs.io/en/latest/topics/channel_
>> layers.html
>>
>> Andrew
>>
>> On Fri, Feb 2, 2018 at 8:52 PM, Ahmed Magdy  wrote:
>>
>>> Aha thanks for making it clear, I will read more about redis then.
>>> Shouldn't the docs mention that though?
>>>
>>> On Saturday, February 3, 2018 at 6:47:47 AM UTC+2, Andrew Godwin wrote:

 No, there is no in-memory channel layer any more, only Redis is
 available at the moment. You must put something into the settings in order
 to make it function.

 Andrew

 On Fri, Feb 2, 2018 at 8:42 PM, Ahmed Magdy  wrote:

> I thought it uses in memory channel layer by default if it's empty? I
> didn't try setting a value, because only redis was available in v2.0.0 and
> I don't like using stuff I don't understand.
>
> On Saturday, F

Re: Django Channels 2.0.0 groups

2018-02-02 Thread Ahmed Magdy
I even made sure to read the docs multiple times before posting. :/

I've been reading about Redis, and since I got windows OS, I installed the 
port for Windows based redis , 
tested the server and client they are working ok 
.

# settings.py
# ...
ASGI_APPLICATION = 'djangoChannels.routing.application'

CHANNEL_LAYERS = {
   "default": {
   "BACKEND": "channels_redis.core.RedisChannelLayer",
   "CONFIG": {
   "hosts": [("localhost", 6379)],
   },
   },
}


# consumers.py
from asgiref.sync import AsyncToSync
from channels.generic.websocket import WebsocketConsumer

class ChatConsumer(WebsocketConsumer):
   def connect(self):
   AsyncToSync(self.channel_layer.group_add)("chat", self.channel_name)

def disconnect(self):
   AsyncToSync(self.channel_layer.group_discard)("chat", self
.channel_name)

raises an exception

[2018/02/03 08:30:19] WebSocket HANDSHAKING /sessions/ [127.0.0.1:12778]
> ERROR:root:Exception inside application: There is no current event loop in 
> thread 'Thread-3'.
>   File "c:\python35\Lib\asyncio\tasks.py", line 241, in _step
> result = coro.throw(exc)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\consumer.py",
>  
> line 51, in __call__
> await await_many_dispatch([receive, self.channel_receive], 
> self.dispatch)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\utils.py", 
> line 48, in await_many_dispatch
> await dispatch(result)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py", 
> line 84, in inner
> return await async_func(*args, **kwargs)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py", 
> line 67, in __call__
> return await asyncio.wait_for(future, timeout=None)
>   File "c:\python35\Lib\asyncio\tasks.py", line 367, in wait_for
> return (yield from fut)
>   File "c:\python35\Lib\asyncio\futures.py", line 358, in __iter__
> yield self  # This tells Task to wait for completion.
>   File "c:\python35\Lib\asyncio\tasks.py", line 290, in _wakeup
> future.result()
>   File "c:\python35\Lib\asyncio\futures.py", line 274, in result
> raise self._exception
>   File "c:\python35\Lib\concurrent\futures\thread.py", line 55, in run
> result = self.fn(*self.args, **self.kwargs)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py", 
> line 76, in thread_handler
> raise e
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py", 
> line 74, in thread_handler
> self.func(*args, **kwargs)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\consumer.py",
>  
> line 93, in dispatch
> handler(message)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\generic\websocket.py",
>  
> line 19, in websocket_connect
> self.connect()
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\husite\djangoChannels\djangoChannels\consumers.py",
>  
> line 7, in connect
> AsyncToSync(self.channel_layer.group_add)("chat", self.channel_name)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py", 
> line 17, in __init__
> self.main_event_loop = asyncio.get_event_loop()
>   File "c:\python35\Lib\asyncio\events.py", line 626, in get_event_loop
> return get_event_loop_policy().get_event_loop()
>   File "c:\python35\Lib\asyncio\events.py", line 572, in get_event_loop
> % threading.current_thread().name)
>   There is no current event loop in thread 'Thread-3'.
>

Thanks for what you did so far!

On Saturday, February 3, 2018 at 6:58:56 AM UTC+2, Andrew Godwin wrote:
>
> The docs do mention this in a big callout at the top of the Channel Layers 
> page :) 
> http://channels.readthedocs.io/en/latest/topics/channel_layers.html
>
> Andrew
>
> On Fri, Feb 2, 2018 at 8:52 PM, Ahmed Magdy  > wrote:
>
>> Aha thanks for making it clear, I will read more about redis then. 
>> Shouldn't the docs mention that though?
>>
>> On Saturday, February 3, 2018 at 6:47:47 AM UTC+2, Andrew Godwin wrote:
>>>
>>> No, there is no in-memory channel layer any more, only Redis is 
>>> available at the moment. You must put something into the settings in order 
>>> to make it function.
>>>
>>> Andrew
>>>
>>> On Fri, Feb 2, 2018 at 8:42 PM, Ahmed Magdy  wrote:
>>>
 I thought it uses in memory channel layer by default if it's empty? I 
 didn't try setting a value, because only redis was available in v2.0.0 and 
 I don't like using stuff I don't understand.

 On Saturday, February 3, 2018 at 6:08:02 AM UTC+2, Andrew Godwin wrote:
>
> It needs to contain a value to work - what value were you trying that 
> was not empty?
>
> Andrew
>
> On Fri, Feb 2, 2018 at 8:04 PM, Ahmed Magdy  
> wrote:
>
>> I tried not having CHANNEL_LAYERS or sett

Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-02 Thread Web Architect
Hi Furbee,

Thanks for your response. 

With my experience I have always noticed that a query within query kills 
the mysql and Mysqld CPU usage hits the ceiling. I would still check your 
alternate. 

I have mentioned the size of A and B in response to Vijay's reply. 

On Saturday, February 3, 2018 at 1:06:48 AM UTC+5:30, Furbee wrote:
>
> There are a couple options you could try to see which is the best fit for 
> your data. With DEBUG=True in settings.py you can check the actual queries 
> and process time. It depends on the sizes of A and B. Another query you can 
> run is:
>
> A.objects.exclude(id__in=B.objects.all().values_list('a_id', flat=True))
>
> When I tried, it seemed to be about the same speed with my test data as 
> the one you had A.objects.filter(bs__isnull=True).
>
> To see what queries are generated and the query time with DEBUG=True:
> Open your Django Python Shell
> >>> A.objects.exclude(id__in=B.objects.all().values_list('a_id', 
> flat=True))
> >>> A.objects.filter(bs__isnull=True)
> >>> from django.db import connection
> >>> for q in connection.queries:
> >>> print("{0}: {1}".format(q['sql'], q['time']))
>
> This will show you both queries generated and how long it took to get a 
> response from your DB.
>
> You can also write raw SQL, if you can make one more efficiently.
>
> Furbee
>
> On Fri, Feb 2, 2018 at 10:56 AM, Vijay Khemlani  > wrote:
>
>> "with large of records in A and B, the above takes lot of time"
>>
>> How long? At first glance it doesn't look like a complex query or 
>> something particularly inefficient for a DB.
>>
>> On Fri, Feb 2, 2018 at 11:31 AM, Andy > 
>> wrote:
>>
>>> not that i know of
>>>
>>>
>>> Am Freitag, 2. Februar 2018 15:28:26 UTC+1 schrieb Web Architect:

 Hi Andy,

 Thanks for your response. I was pondering on option a before posting 
 this query thinking there could be better ways in django/SQL to handle 
 this. But now I would probably go with a.

 Thanks.

 On Friday, February 2, 2018 at 7:50:53 PM UTC+5:30, Andy wrote:
>
> a) Maybe its an option to put the foreign key to the other model? This 
> way you dont need to make a join to find out if there is a relation.
>
> b) Save the existing ralation status to model A
>
> c) cache the A.objects.filter(bs__isnull=False) query
>
> But apart from that i fear you cannot do much more, since this is just 
> a DB and not a Django ORM question.
>
>
> Am Freitag, 2. Februar 2018 14:47:45 UTC+1 schrieb Web Architect:
>>
>> Hi,
>>
>> I am trying to optimise Django queries on my ecommerce website. One 
>> of the fundamental query is where I have no clue how to make efficient. 
>> It 
>> could be trivial and probably been known long time back. But I am new to 
>> Django and would appreciate any help. This is primarily for one to many 
>> or 
>> many to many relations.
>>
>> Following is an example scenario:
>> (Please pardon my syntax as I want to put across the concept and not 
>> the exact django code unless it's really needed):
>>
>> Model A:
>>
>> class A(models.Model):
>> # Fields of model A
>>
>> Model B (which is related to A with foreign key):
>>
>> class B(models.Model):
>> a = models.ForeignKey('A', related_name='bs')
>>
>> Now I would like to find out all As for which there is atleast one b. 
>> The only way I know is as follows:
>>
>> A.objects.filter(bs__isnull=False)
>>
>> But the above isn't an optimal way as with large of records in A and 
>> B, the above takes lot of time. It gets more inefficient if it's a many 
>> to 
>> many relationship.
>>
>> Could anyone please let me know the most efficient way to use django 
>> queryset for the above scenario?
>>
>> Thanks.
>>
> -- 
>>> 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/73ed5ff7-d4db-4057-a812-01c82bf08cf3%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

Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-02 Thread Web Architect
Hi Vijay,

Thanks for your response.

In my scenario, there is also another model with manytomany relation with A:

class C(models.Model):
a = manytomany('A', related_name='cs', through='D')

so, for around 25K records in A, 45K records in D and 18K records in B, 
following query takes more than 300ms and sometimes more than 500ms:

A.objects.filter(bs__isnull=False, cs__isnull=False).

Thanks.

On Saturday, February 3, 2018 at 12:28:38 AM UTC+5:30, Vijay Khemlani wrote:
>
> "with large of records in A and B, the above takes lot of time"
>
> How long? At first glance it doesn't look like a complex query or 
> something particularly inefficient for a DB.
>
> On Fri, Feb 2, 2018 at 11:31 AM, Andy > 
> wrote:
>
>> not that i know of
>>
>>
>> Am Freitag, 2. Februar 2018 15:28:26 UTC+1 schrieb Web Architect:
>>>
>>> Hi Andy,
>>>
>>> Thanks for your response. I was pondering on option a before posting 
>>> this query thinking there could be better ways in django/SQL to handle 
>>> this. But now I would probably go with a.
>>>
>>> Thanks.
>>>
>>> On Friday, February 2, 2018 at 7:50:53 PM UTC+5:30, Andy wrote:

 a) Maybe its an option to put the foreign key to the other model? This 
 way you dont need to make a join to find out if there is a relation.

 b) Save the existing ralation status to model A

 c) cache the A.objects.filter(bs__isnull=False) query

 But apart from that i fear you cannot do much more, since this is just 
 a DB and not a Django ORM question.


 Am Freitag, 2. Februar 2018 14:47:45 UTC+1 schrieb Web Architect:
>
> Hi,
>
> I am trying to optimise Django queries on my ecommerce website. One of 
> the fundamental query is where I have no clue how to make efficient. It 
> could be trivial and probably been known long time back. But I am new to 
> Django and would appreciate any help. This is primarily for one to many 
> or 
> many to many relations.
>
> Following is an example scenario:
> (Please pardon my syntax as I want to put across the concept and not 
> the exact django code unless it's really needed):
>
> Model A:
>
> class A(models.Model):
> # Fields of model A
>
> Model B (which is related to A with foreign key):
>
> class B(models.Model):
> a = models.ForeignKey('A', related_name='bs')
>
> Now I would like to find out all As for which there is atleast one b. 
> The only way I know is as follows:
>
> A.objects.filter(bs__isnull=False)
>
> But the above isn't an optimal way as with large of records in A and 
> B, the above takes lot of time. It gets more inefficient if it's a many 
> to 
> many relationship.
>
> Could anyone please let me know the most efficient way to use django 
> queryset for the above scenario?
>
> Thanks.
>
 -- 
>> 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/73ed5ff7-d4db-4057-a812-01c82bf08cf3%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/e8097811-a1de-44c2-9d9a-0457f1ead77f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Customizable Invoice

2018-02-02 Thread Rakhee Menon
Oops!!I am sorry !! I got your question wrong.Yes I do have some knowledge 
about django. Just wanted to know whether its possible and any solution if 
u could suggest.
Anways Thanks a lot :)

On Friday, February 2, 2018 at 3:20:21 PM UTC+5:30, Andy wrote:
>
> Well since your answer is no, you should take you time and learn 
> Python/Dajngo before asking anyone in here to basically write that invoice 
> app for you. :)
>
> Basically Django can do what you are asking for, but i'd recommend you to 
> use it only as a backend for this highly UI focused problem. Then think 
> about what the frontend will be (web, app, mobile) and choose something 
> that has the needed frontend components that you would like to use. 
>
> But let me tell you this: a totally customizable invoice with that shall 
> still look pretty and can be printed out in any combination of item rows 
> and extra details is probably one of the hardest tasks you can think of not 
> having any programming background!
> Having kinda done the above i can definitely recommend the awesome 
> https://github.com/Kozea/WeasyPrint library for generating PDF files!
>
> But it sounds to me that you should do yourself a favour and read this 
> before actually starting your project: 
> https://www.twoscoopspress.com/products/two-scoops-of-django-1-11
>
> Have fun!
>
>  
>
> Am Freitag, 2. Februar 2018 10:24:31 UTC+1 schrieb Rakhee Menon:
>>
>>
>>
>> No...I wanted to know if i could do it using django and if yes...how to 
>> do it??
>>
>

-- 
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/a6355ed1-16bc-4980-89c4-4686e540422a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Channels 2.0.0 groups

2018-02-02 Thread Andrew Godwin
The docs do mention this in a big callout at the top of the Channel Layers
page :) http://channels.readthedocs.io/en/latest/topics/channel_layers.html

Andrew

On Fri, Feb 2, 2018 at 8:52 PM, Ahmed Magdy  wrote:

> Aha thanks for making it clear, I will read more about redis then.
> Shouldn't the docs mention that though?
>
> On Saturday, February 3, 2018 at 6:47:47 AM UTC+2, Andrew Godwin wrote:
>>
>> No, there is no in-memory channel layer any more, only Redis is available
>> at the moment. You must put something into the settings in order to make it
>> function.
>>
>> Andrew
>>
>> On Fri, Feb 2, 2018 at 8:42 PM, Ahmed Magdy  wrote:
>>
>>> I thought it uses in memory channel layer by default if it's empty? I
>>> didn't try setting a value, because only redis was available in v2.0.0 and
>>> I don't like using stuff I don't understand.
>>>
>>> On Saturday, February 3, 2018 at 6:08:02 AM UTC+2, Andrew Godwin wrote:

 It needs to contain a value to work - what value were you trying that
 was not empty?

 Andrew

 On Fri, Feb 2, 2018 at 8:04 PM, Ahmed Magdy  wrote:

> I tried not having CHANNEL_LAYERS or setting it to {}
> same exception
>
> On Saturday, February 3, 2018 at 3:36:43 AM UTC+2, Andrew Godwin wrote:
>>
>> Do you have a CHANNEL_LAYERS setting in your settings file? If so,
>> what is it set to?
>>
>> Andrew
>>
>> On Fri, Feb 2, 2018 at 5:17 PM, Ahmed Magdy 
>> wrote:
>>
>>> That's what I did after reading the documentation here's how my
>>> channels files look like
>>>
>>> # settings.py
>>> # ...
>>> ASGI_APPLICATION = 'djangoChannels.routing.application'
>>> # ...
>>>
>>> # routing.py
>>> from django.conf.urls import url
>>>
>>> from channels.routing import ProtocolTypeRouter, URLRouter
>>> from channels.auth import AuthMiddlewareStack
>>>
>>> from .consumers import ChatConsumer
>>>
>>> application = ProtocolTypeRouter({
>>># Empty for now (http->django views is added by default)
>>>'websocket': AuthMiddlewareStack(
>>>URLRouter([
>>>url('^sessions/$', ChatConsumer)
>>>])
>>>)
>>> })
>>>
>>> # consumers.py
>>> from asgiref.sync import AsyncToSync
>>> from channels.generic.websocket import WebsocketConsumer
>>>
>>> class ChatConsumer(WebsocketConsumer):
>>>
>>> def connect(self):
>>>AsyncToSync(self.channel_layer.group_add)("chat", self
>>> .channel_name)
>>>
>>> def disconnect(self):
>>>AsyncToSync(self.channel_layer.group_discard)("chat", self
>>> .channel_name)
>>>
>>>
>>> After connecting with JS websocket to
>>>
>>> ws://127.0.0.1:8000/sessions/

>>>
>>> Raises an exception
>>>
>>> Performing system checks...

 System check identified no issues (0 silenced).
 February 03, 2018 - 03:14:29
 Django version 2.0.2, using settings 'djangoChannels.settings'
 Starting ASGI/Channels development server at http://127.0.0.1:8000/
 Quit the server with CTRL-BREAK.
 2018-02-03 03:14:29,799 - INFO - server - HTTP/2 support not
 enabled (install the http2 and tls Twisted extras)
 2018-02-03 03:14:29,800 - INFO - server - Listening on endpoint
 tcp:port=8000:interface=127.0.0.1
 [2018/02/03 03:14:32] WebSocket HANDSHAKING /sessions/ [
 127.0.0.1:8631]
 ERROR:root:Exception inside application: 'NoneType' object has no
 attribute 'group_add'
   File "c:\python35\Lib\asyncio\tasks.py", line 241, in _step
 result = coro.throw(exc)
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\consumer.py",
 line 53, in __call__
 await await_many_dispatch([receive], self.dispatch)
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\utils.py",
 line 48, in await_many_dispatch
 await dispatch(result)
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
 line 84, in inner
 return await async_func(*args, **kwargs)
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
 line 67, in __call__
 return await asyncio.wait_for(future, timeout=None)
   File "c:\python35\Lib\asyncio\tasks.py", line 367, in wait_for
 return (yield from fut)
   File "c:\python35\Lib\asyncio\futures.py", line 358, in __iter__
 yield self  # This tells Task to wait for completion.
   File "c:\python35\Lib\asyncio\tasks.py", line 290, in _wakeup
 future.result()
   File "c:\python35\Lib\asyncio\futures.py", line 274, in result
 raise self._exception
   F

Re: Django Channels 2.0.0 groups

2018-02-02 Thread Ahmed Magdy
Aha thanks for making it clear, I will read more about redis then. 
Shouldn't the docs mention that though?

On Saturday, February 3, 2018 at 6:47:47 AM UTC+2, Andrew Godwin wrote:
>
> No, there is no in-memory channel layer any more, only Redis is available 
> at the moment. You must put something into the settings in order to make it 
> function.
>
> Andrew
>
> On Fri, Feb 2, 2018 at 8:42 PM, Ahmed Magdy  > wrote:
>
>> I thought it uses in memory channel layer by default if it's empty? I 
>> didn't try setting a value, because only redis was available in v2.0.0 and 
>> I don't like using stuff I don't understand.
>>
>> On Saturday, February 3, 2018 at 6:08:02 AM UTC+2, Andrew Godwin wrote:
>>>
>>> It needs to contain a value to work - what value were you trying that 
>>> was not empty?
>>>
>>> Andrew
>>>
>>> On Fri, Feb 2, 2018 at 8:04 PM, Ahmed Magdy  wrote:
>>>
 I tried not having CHANNEL_LAYERS or setting it to {} 
 same exception

 On Saturday, February 3, 2018 at 3:36:43 AM UTC+2, Andrew Godwin wrote:
>
> Do you have a CHANNEL_LAYERS setting in your settings file? If so, 
> what is it set to?
>
> Andrew
>
> On Fri, Feb 2, 2018 at 5:17 PM, Ahmed Magdy  
> wrote:
>
>> That's what I did after reading the documentation here's how my 
>> channels files look like
>>
>> # settings.py
>> # ...
>> ASGI_APPLICATION = 'djangoChannels.routing.application'
>> # ...
>>
>> # routing.py
>> from django.conf.urls import url
>>
>> from channels.routing import ProtocolTypeRouter, URLRouter
>> from channels.auth import AuthMiddlewareStack
>>
>> from .consumers import ChatConsumer
>>
>> application = ProtocolTypeRouter({
>># Empty for now (http->django views is added by default)
>>'websocket': AuthMiddlewareStack(
>>URLRouter([
>>url('^sessions/$', ChatConsumer)
>>])
>>)
>> })
>>
>> # consumers.py
>> from asgiref.sync import AsyncToSync
>> from channels.generic.websocket import WebsocketConsumer
>>
>> class ChatConsumer(WebsocketConsumer):
>>
>> def connect(self):
>>AsyncToSync(self.channel_layer.group_add)("chat", self
>> .channel_name)
>>
>> def disconnect(self):
>>AsyncToSync(self.channel_layer.group_discard)("chat", self
>> .channel_name)
>>
>>
>> After connecting with JS websocket to 
>>
>> ws://127.0.0.1:8000/sessions/
>>>
>>
>> Raises an exception
>>
>> Performing system checks...
>>>
>>> System check identified no issues (0 silenced).
>>> February 03, 2018 - 03:14:29
>>> Django version 2.0.2, using settings 'djangoChannels.settings'
>>> Starting ASGI/Channels development server at http://127.0.0.1:8000/
>>> Quit the server with CTRL-BREAK.
>>> 2018-02-03 03:14:29,799 - INFO - server - HTTP/2 support not enabled 
>>> (install the http2 and tls Twisted extras)
>>> 2018-02-03 03:14:29,800 - INFO - server - Listening on endpoint 
>>> tcp:port=8000:interface=127.0.0.1
>>> [2018/02/03 03:14:32] WebSocket HANDSHAKING /sessions/ [
>>> 127.0.0.1:8631]
>>> ERROR:root:Exception inside application: 'NoneType' object has no 
>>> attribute 'group_add'
>>>   File "c:\python35\Lib\asyncio\tasks.py", line 241, in _step
>>> result = coro.throw(exc)
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\consumer.py",
>>>  
>>> line 53, in __call__
>>> await await_many_dispatch([receive], self.dispatch)
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\utils.py",
>>>  
>>> line 48, in await_many_dispatch
>>> await dispatch(result)
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
>>>  
>>> line 84, in inner
>>> return await async_func(*args, **kwargs)
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
>>>  
>>> line 67, in __call__
>>> return await asyncio.wait_for(future, timeout=None)
>>>   File "c:\python35\Lib\asyncio\tasks.py", line 367, in wait_for
>>> return (yield from fut)
>>>   File "c:\python35\Lib\asyncio\futures.py", line 358, in __iter__
>>> yield self  # This tells Task to wait for completion.
>>>   File "c:\python35\Lib\asyncio\tasks.py", line 290, in _wakeup
>>> future.result()
>>>   File "c:\python35\Lib\asyncio\futures.py", line 274, in result
>>> raise self._exception
>>>   File "c:\python35\Lib\concurrent\futures\thread.py", line 55, in 
>>> run
>>> result = self.fn(*self.args, **self.kwargs)
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
>>>  
>>> line 76, in thread_handler
>>>   

Re: Django Channels 2.0.0 groups

2018-02-02 Thread Andrew Godwin
No, there is no in-memory channel layer any more, only Redis is available
at the moment. You must put something into the settings in order to make it
function.

Andrew

On Fri, Feb 2, 2018 at 8:42 PM, Ahmed Magdy  wrote:

> I thought it uses in memory channel layer by default if it's empty? I
> didn't try setting a value, because only redis was available in v2.0.0 and
> I don't like using stuff I don't understand.
>
> On Saturday, February 3, 2018 at 6:08:02 AM UTC+2, Andrew Godwin wrote:
>>
>> It needs to contain a value to work - what value were you trying that was
>> not empty?
>>
>> Andrew
>>
>> On Fri, Feb 2, 2018 at 8:04 PM, Ahmed Magdy  wrote:
>>
>>> I tried not having CHANNEL_LAYERS or setting it to {}
>>> same exception
>>>
>>> On Saturday, February 3, 2018 at 3:36:43 AM UTC+2, Andrew Godwin wrote:

 Do you have a CHANNEL_LAYERS setting in your settings file? If so, what
 is it set to?

 Andrew

 On Fri, Feb 2, 2018 at 5:17 PM, Ahmed Magdy  wrote:

> That's what I did after reading the documentation here's how my
> channels files look like
>
> # settings.py
> # ...
> ASGI_APPLICATION = 'djangoChannels.routing.application'
> # ...
>
> # routing.py
> from django.conf.urls import url
>
> from channels.routing import ProtocolTypeRouter, URLRouter
> from channels.auth import AuthMiddlewareStack
>
> from .consumers import ChatConsumer
>
> application = ProtocolTypeRouter({
># Empty for now (http->django views is added by default)
>'websocket': AuthMiddlewareStack(
>URLRouter([
>url('^sessions/$', ChatConsumer)
>])
>)
> })
>
> # consumers.py
> from asgiref.sync import AsyncToSync
> from channels.generic.websocket import WebsocketConsumer
>
> class ChatConsumer(WebsocketConsumer):
>
> def connect(self):
>AsyncToSync(self.channel_layer.group_add)("chat", self
> .channel_name)
>
> def disconnect(self):
>AsyncToSync(self.channel_layer.group_discard)("chat", self
> .channel_name)
>
>
> After connecting with JS websocket to
>
> ws://127.0.0.1:8000/sessions/
>>
>
> Raises an exception
>
> Performing system checks...
>>
>> System check identified no issues (0 silenced).
>> February 03, 2018 - 03:14:29
>> Django version 2.0.2, using settings 'djangoChannels.settings'
>> Starting ASGI/Channels development server at http://127.0.0.1:8000/
>> Quit the server with CTRL-BREAK.
>> 2018-02-03 03:14:29,799 - INFO - server - HTTP/2 support not enabled
>> (install the http2 and tls Twisted extras)
>> 2018-02-03 03:14:29,800 - INFO - server - Listening on endpoint
>> tcp:port=8000:interface=127.0.0.1
>> [2018/02/03 03:14:32] WebSocket HANDSHAKING /sessions/ [
>> 127.0.0.1:8631]
>> ERROR:root:Exception inside application: 'NoneType' object has no
>> attribute 'group_add'
>>   File "c:\python35\Lib\asyncio\tasks.py", line 241, in _step
>> result = coro.throw(exc)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\consumer.py",
>> line 53, in __call__
>> await await_many_dispatch([receive], self.dispatch)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\utils.py",
>> line 48, in await_many_dispatch
>> await dispatch(result)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
>> line 84, in inner
>> return await async_func(*args, **kwargs)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
>> line 67, in __call__
>> return await asyncio.wait_for(future, timeout=None)
>>   File "c:\python35\Lib\asyncio\tasks.py", line 367, in wait_for
>> return (yield from fut)
>>   File "c:\python35\Lib\asyncio\futures.py", line 358, in __iter__
>> yield self  # This tells Task to wait for completion.
>>   File "c:\python35\Lib\asyncio\tasks.py", line 290, in _wakeup
>> future.result()
>>   File "c:\python35\Lib\asyncio\futures.py", line 274, in result
>> raise self._exception
>>   File "c:\python35\Lib\concurrent\futures\thread.py", line 55, in
>> run
>> result = self.fn(*self.args, **self.kwargs)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
>> line 76, in thread_handler
>> raise e
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
>> line 74, in thread_handler
>> self.func(*args, **kwargs)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\consumer.py",
>> line 93, in dispatch
>> handler(message)
>>   File 
>> "D:\Programming\DjangoWebsi

Re: Django Channels 2.0.0 groups

2018-02-02 Thread Ahmed Magdy
I thought it uses in memory channel layer by default if it's empty? I 
didn't try setting a value, because only redis was available in v2.0.0 and 
I don't like using stuff I don't understand.

On Saturday, February 3, 2018 at 6:08:02 AM UTC+2, Andrew Godwin wrote:
>
> It needs to contain a value to work - what value were you trying that was 
> not empty?
>
> Andrew
>
> On Fri, Feb 2, 2018 at 8:04 PM, Ahmed Magdy  > wrote:
>
>> I tried not having CHANNEL_LAYERS or setting it to {} 
>> same exception
>>
>> On Saturday, February 3, 2018 at 3:36:43 AM UTC+2, Andrew Godwin wrote:
>>>
>>> Do you have a CHANNEL_LAYERS setting in your settings file? If so, what 
>>> is it set to?
>>>
>>> Andrew
>>>
>>> On Fri, Feb 2, 2018 at 5:17 PM, Ahmed Magdy  wrote:
>>>
 That's what I did after reading the documentation here's how my 
 channels files look like

 # settings.py
 # ...
 ASGI_APPLICATION = 'djangoChannels.routing.application'
 # ...

 # routing.py
 from django.conf.urls import url

 from channels.routing import ProtocolTypeRouter, URLRouter
 from channels.auth import AuthMiddlewareStack

 from .consumers import ChatConsumer

 application = ProtocolTypeRouter({
# Empty for now (http->django views is added by default)
'websocket': AuthMiddlewareStack(
URLRouter([
url('^sessions/$', ChatConsumer)
])
)
 })

 # consumers.py
 from asgiref.sync import AsyncToSync
 from channels.generic.websocket import WebsocketConsumer

 class ChatConsumer(WebsocketConsumer):

 def connect(self):
AsyncToSync(self.channel_layer.group_add)("chat", self
 .channel_name)

 def disconnect(self):
AsyncToSync(self.channel_layer.group_discard)("chat", self
 .channel_name)


 After connecting with JS websocket to 

 ws://127.0.0.1:8000/sessions/
>

 Raises an exception

 Performing system checks...
>
> System check identified no issues (0 silenced).
> February 03, 2018 - 03:14:29
> Django version 2.0.2, using settings 'djangoChannels.settings'
> Starting ASGI/Channels development server at http://127.0.0.1:8000/
> Quit the server with CTRL-BREAK.
> 2018-02-03 03:14:29,799 - INFO - server - HTTP/2 support not enabled 
> (install the http2 and tls Twisted extras)
> 2018-02-03 03:14:29,800 - INFO - server - Listening on endpoint 
> tcp:port=8000:interface=127.0.0.1
> [2018/02/03 03:14:32] WebSocket HANDSHAKING /sessions/ [127.0.0.1:8631
> ]
> ERROR:root:Exception inside application: 'NoneType' object has no 
> attribute 'group_add'
>   File "c:\python35\Lib\asyncio\tasks.py", line 241, in _step
> result = coro.throw(exc)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\consumer.py",
>  
> line 53, in __call__
> await await_many_dispatch([receive], self.dispatch)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\utils.py",
>  
> line 48, in await_many_dispatch
> await dispatch(result)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
>  
> line 84, in inner
> return await async_func(*args, **kwargs)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
>  
> line 67, in __call__
> return await asyncio.wait_for(future, timeout=None)
>   File "c:\python35\Lib\asyncio\tasks.py", line 367, in wait_for
> return (yield from fut)
>   File "c:\python35\Lib\asyncio\futures.py", line 358, in __iter__
> yield self  # This tells Task to wait for completion.
>   File "c:\python35\Lib\asyncio\tasks.py", line 290, in _wakeup
> future.result()
>   File "c:\python35\Lib\asyncio\futures.py", line 274, in result
> raise self._exception
>   File "c:\python35\Lib\concurrent\futures\thread.py", line 55, in run
> result = self.fn(*self.args, **self.kwargs)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
>  
> line 76, in thread_handler
> raise e
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
>  
> line 74, in thread_handler
> self.func(*args, **kwargs)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\consumer.py",
>  
> line 93, in dispatch
> handler(message)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\generic\websocket.py",
>  
> line 19, in websocket_connect
> self.connect()
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\husite\djangoChannels\djangoChannels\consumers.py",
>  
> line 8, in connect
> AsyncTo

Re: In the Admin, Is it possible to make filters on foreign keys usable with lots of related objects?

2018-02-02 Thread Andy
No you didn’t miss anything. He did not understand your question. 
But like I said before you can always build your own filter. Your problem is 
highly custom to your DB and model relations. You can’t expect any framework to 
already have a matching component for that. 

In my 9 years of Django development I never needed what you expect to be there. 

-- 
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/706c9c9d-9f23-43bd-98f0-e221e2be13ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Channels 2.0.0 groups

2018-02-02 Thread Andrew Godwin
It needs to contain a value to work - what value were you trying that was
not empty?

Andrew

On Fri, Feb 2, 2018 at 8:04 PM, Ahmed Magdy  wrote:

> I tried not having CHANNEL_LAYERS or setting it to {}
> same exception
>
> On Saturday, February 3, 2018 at 3:36:43 AM UTC+2, Andrew Godwin wrote:
>>
>> Do you have a CHANNEL_LAYERS setting in your settings file? If so, what
>> is it set to?
>>
>> Andrew
>>
>> On Fri, Feb 2, 2018 at 5:17 PM, Ahmed Magdy  wrote:
>>
>>> That's what I did after reading the documentation here's how my channels
>>> files look like
>>>
>>> # settings.py
>>> # ...
>>> ASGI_APPLICATION = 'djangoChannels.routing.application'
>>> # ...
>>>
>>> # routing.py
>>> from django.conf.urls import url
>>>
>>> from channels.routing import ProtocolTypeRouter, URLRouter
>>> from channels.auth import AuthMiddlewareStack
>>>
>>> from .consumers import ChatConsumer
>>>
>>> application = ProtocolTypeRouter({
>>># Empty for now (http->django views is added by default)
>>>'websocket': AuthMiddlewareStack(
>>>URLRouter([
>>>url('^sessions/$', ChatConsumer)
>>>])
>>>)
>>> })
>>>
>>> # consumers.py
>>> from asgiref.sync import AsyncToSync
>>> from channels.generic.websocket import WebsocketConsumer
>>>
>>> class ChatConsumer(WebsocketConsumer):
>>>
>>> def connect(self):
>>>AsyncToSync(self.channel_layer.group_add)("chat", self
>>> .channel_name)
>>>
>>> def disconnect(self):
>>>AsyncToSync(self.channel_layer.group_discard)("chat", self
>>> .channel_name)
>>>
>>>
>>> After connecting with JS websocket to
>>>
>>> ws://127.0.0.1:8000/sessions/

>>>
>>> Raises an exception
>>>
>>> Performing system checks...

 System check identified no issues (0 silenced).
 February 03, 2018 - 03:14:29
 Django version 2.0.2, using settings 'djangoChannels.settings'
 Starting ASGI/Channels development server at http://127.0.0.1:8000/
 Quit the server with CTRL-BREAK.
 2018-02-03 03:14:29,799 - INFO - server - HTTP/2 support not enabled
 (install the http2 and tls Twisted extras)
 2018-02-03 03:14:29,800 - INFO - server - Listening on endpoint
 tcp:port=8000:interface=127.0.0.1
 [2018/02/03 03:14:32] WebSocket HANDSHAKING /sessions/ [127.0.0.1:8631]
 ERROR:root:Exception inside application: 'NoneType' object has no
 attribute 'group_add'
   File "c:\python35\Lib\asyncio\tasks.py", line 241, in _step
 result = coro.throw(exc)
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\consumer.py",
 line 53, in __call__
 await await_many_dispatch([receive], self.dispatch)
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\utils.py",
 line 48, in await_many_dispatch
 await dispatch(result)
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
 line 84, in inner
 return await async_func(*args, **kwargs)
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
 line 67, in __call__
 return await asyncio.wait_for(future, timeout=None)
   File "c:\python35\Lib\asyncio\tasks.py", line 367, in wait_for
 return (yield from fut)
   File "c:\python35\Lib\asyncio\futures.py", line 358, in __iter__
 yield self  # This tells Task to wait for completion.
   File "c:\python35\Lib\asyncio\tasks.py", line 290, in _wakeup
 future.result()
   File "c:\python35\Lib\asyncio\futures.py", line 274, in result
 raise self._exception
   File "c:\python35\Lib\concurrent\futures\thread.py", line 55, in run
 result = self.fn(*self.args, **self.kwargs)
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
 line 76, in thread_handler
 raise e
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
 line 74, in thread_handler
 self.func(*args, **kwargs)
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\consumer.py",
 line 93, in dispatch
 handler(message)
   File 
 "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\generic\websocket.py",
 line 19, in websocket_connect
 self.connect()
   File "D:\Programming\DjangoWebsite\HUWebsite\husite\djangoChannel
 s\djangoChannels\consumers.py", line 8, in connect
 AsyncToSync(self.channel_layer.group_add)("chat",
 self.channel_name)
   'NoneType' object has no attribute 'group_add'
 [2018/02/03 03:14:32] WebSocket DISCONNECT /sessions/ [127.0.0.1:8631]

>>>
>>>
>>> On Friday, February 2, 2018 at 7:37:36 PM UTC+2, Andrew Godwin wrote:

 Hi Ahmed,

 In the new release channel layers are optional - if you don't configure
 them they will indeed come through as None. The settings format changed
 slightly too - you can re

Re: Django Channels 2.0.0 groups

2018-02-02 Thread Ahmed Magdy
I tried not having CHANNEL_LAYERS or setting it to {} 
same exception

On Saturday, February 3, 2018 at 3:36:43 AM UTC+2, Andrew Godwin wrote:
>
> Do you have a CHANNEL_LAYERS setting in your settings file? If so, what is 
> it set to?
>
> Andrew
>
> On Fri, Feb 2, 2018 at 5:17 PM, Ahmed Magdy  > wrote:
>
>> That's what I did after reading the documentation here's how my channels 
>> files look like
>>
>> # settings.py
>> # ...
>> ASGI_APPLICATION = 'djangoChannels.routing.application'
>> # ...
>>
>> # routing.py
>> from django.conf.urls import url
>>
>> from channels.routing import ProtocolTypeRouter, URLRouter
>> from channels.auth import AuthMiddlewareStack
>>
>> from .consumers import ChatConsumer
>>
>> application = ProtocolTypeRouter({
>># Empty for now (http->django views is added by default)
>>'websocket': AuthMiddlewareStack(
>>URLRouter([
>>url('^sessions/$', ChatConsumer)
>>])
>>)
>> })
>>
>> # consumers.py
>> from asgiref.sync import AsyncToSync
>> from channels.generic.websocket import WebsocketConsumer
>>
>> class ChatConsumer(WebsocketConsumer):
>>
>> def connect(self):
>>AsyncToSync(self.channel_layer.group_add)("chat", self
>> .channel_name)
>>
>> def disconnect(self):
>>AsyncToSync(self.channel_layer.group_discard)("chat", self
>> .channel_name)
>>
>>
>> After connecting with JS websocket to 
>>
>> ws://127.0.0.1:8000/sessions/
>>>
>>
>> Raises an exception
>>
>> Performing system checks...
>>>
>>> System check identified no issues (0 silenced).
>>> February 03, 2018 - 03:14:29
>>> Django version 2.0.2, using settings 'djangoChannels.settings'
>>> Starting ASGI/Channels development server at http://127.0.0.1:8000/
>>> Quit the server with CTRL-BREAK.
>>> 2018-02-03 03:14:29,799 - INFO - server - HTTP/2 support not enabled 
>>> (install the http2 and tls Twisted extras)
>>> 2018-02-03 03:14:29,800 - INFO - server - Listening on endpoint 
>>> tcp:port=8000:interface=127.0.0.1
>>> [2018/02/03 03:14:32] WebSocket HANDSHAKING /sessions/ [127.0.0.1:8631]
>>> ERROR:root:Exception inside application: 'NoneType' object has no 
>>> attribute 'group_add'
>>>   File "c:\python35\Lib\asyncio\tasks.py", line 241, in _step
>>> result = coro.throw(exc)
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\consumer.py",
>>>  
>>> line 53, in __call__
>>> await await_many_dispatch([receive], self.dispatch)
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\utils.py",
>>>  
>>> line 48, in await_many_dispatch
>>> await dispatch(result)
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py", 
>>> line 84, in inner
>>> return await async_func(*args, **kwargs)
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py", 
>>> line 67, in __call__
>>> return await asyncio.wait_for(future, timeout=None)
>>>   File "c:\python35\Lib\asyncio\tasks.py", line 367, in wait_for
>>> return (yield from fut)
>>>   File "c:\python35\Lib\asyncio\futures.py", line 358, in __iter__
>>> yield self  # This tells Task to wait for completion.
>>>   File "c:\python35\Lib\asyncio\tasks.py", line 290, in _wakeup
>>> future.result()
>>>   File "c:\python35\Lib\asyncio\futures.py", line 274, in result
>>> raise self._exception
>>>   File "c:\python35\Lib\concurrent\futures\thread.py", line 55, in run
>>> result = self.fn(*self.args, **self.kwargs)
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py", 
>>> line 76, in thread_handler
>>> raise e
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py", 
>>> line 74, in thread_handler
>>> self.func(*args, **kwargs)
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\consumer.py",
>>>  
>>> line 93, in dispatch
>>> handler(message)
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\generic\websocket.py",
>>>  
>>> line 19, in websocket_connect
>>> self.connect()
>>>   File 
>>> "D:\Programming\DjangoWebsite\HUWebsite\husite\djangoChannels\djangoChannels\consumers.py",
>>>  
>>> line 8, in connect
>>> AsyncToSync(self.channel_layer.group_add)("chat", self.channel_name)
>>>   'NoneType' object has no attribute 'group_add'
>>> [2018/02/03 03:14:32] WebSocket DISCONNECT /sessions/ [127.0.0.1:8631]
>>>
>>
>>
>> On Friday, February 2, 2018 at 7:37:36 PM UTC+2, Andrew Godwin wrote:
>>>
>>> Hi Ahmed,
>>>
>>> In the new release channel layers are optional - if you don't configure 
>>> them they will indeed come through as None. The settings format changed 
>>> slightly too - you can read more here: 
>>> http://channels.readthedocs.io/en/latest/topics/channel_layers.html
>>>
>>> Andrew
>>>
>>> On Fri, Feb 2, 2018 at 3:31 AM, Ahmed Magdy  wrote:
>>>
 I'm relatively new to channels and was using Channels v1.x.x groups

Re: Django

2018-02-02 Thread Jung Hoon Park
Thank you very much Rocha, I come to understand  that import statement 
checks the module and its submodule specified in from clause.

2018년 2월 2일 금요일 오후 1시 28분 57초 UTC+9, sacrac 님의 말:
>
> path is call from django.urls
> https://github.com/django/django/blob/master/django/urls/conf.py
> you need use Django 2.0.x and python3 for work path
>
> Cheers
>
> On Thu, Feb 1, 2018 at 7:09 PM, Jung Hoon Park  > wrote:
>
>> Hi Rocha,
>> There is "from django.urls import path" statement on the top. 
>> Does it mean that path function is defined somewhere, not in this urls.py 
>> file?
>>
>> 2018년 2월 2일 금요일 오전 7시 52분 15초 UTC+9, sacrac 님의 말:
>>>
>>> To create a URLconf in the polls directory, create a file called urls.py. 
>>> Your app directory should now look like:
>>>
>>> On Wed, Jan 31, 2018 at 8:42 PM, Jung Hoon Park  
>>> wrote:
>>>
 Hello, I am studying Django for my new project.
 I am confronting very basic problem. 
 In Tutorial Part1. Request and Response, Django Documentation, 
 following sorce code is there.
  But I cannot find path function in "~/django.urls" directory.
 Can a function be imported which has no defintion in "from location"?


 polls/urls.py

 from django.urls import path
 from . import views
 urlpatterns = [
 path('', views.index, name='index'),]

 -- 
 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/0e088428-2daa-4ce1-b089-95e30d129948%40googlegroups.com
  
 
 .
 For more options, visit https://groups.google.com/d/optout.

>>>
>>>
>>>
>>> -- 
>>> att.
>>> Carlos Rocha
>>>
>> -- 
>> 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/7a133978-4696-4d44-a13a-665d9f4f4661%40googlegroups.com
>>  
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> att.
> Carlos Rocha
>

-- 
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/394c53e6-0c80-4da6-a407-917746ea17f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Channels 2.0.0 groups

2018-02-02 Thread Andrew Godwin
Do you have a CHANNEL_LAYERS setting in your settings file? If so, what is
it set to?

Andrew

On Fri, Feb 2, 2018 at 5:17 PM, Ahmed Magdy  wrote:

> That's what I did after reading the documentation here's how my channels
> files look like
>
> # settings.py
> # ...
> ASGI_APPLICATION = 'djangoChannels.routing.application'
> # ...
>
> # routing.py
> from django.conf.urls import url
>
> from channels.routing import ProtocolTypeRouter, URLRouter
> from channels.auth import AuthMiddlewareStack
>
> from .consumers import ChatConsumer
>
> application = ProtocolTypeRouter({
># Empty for now (http->django views is added by default)
>'websocket': AuthMiddlewareStack(
>URLRouter([
>url('^sessions/$', ChatConsumer)
>])
>)
> })
>
> # consumers.py
> from asgiref.sync import AsyncToSync
> from channels.generic.websocket import WebsocketConsumer
>
> class ChatConsumer(WebsocketConsumer):
>
> def connect(self):
>AsyncToSync(self.channel_layer.group_add)("chat", self
> .channel_name)
>
> def disconnect(self):
>AsyncToSync(self.channel_layer.group_discard)("chat", self
> .channel_name)
>
>
> After connecting with JS websocket to
>
> ws://127.0.0.1:8000/sessions/
>>
>
> Raises an exception
>
> Performing system checks...
>>
>> System check identified no issues (0 silenced).
>> February 03, 2018 - 03:14:29
>> Django version 2.0.2, using settings 'djangoChannels.settings'
>> Starting ASGI/Channels development server at http://127.0.0.1:8000/
>> Quit the server with CTRL-BREAK.
>> 2018-02-03 03:14:29,799 - INFO - server - HTTP/2 support not enabled
>> (install the http2 and tls Twisted extras)
>> 2018-02-03 03:14:29,800 - INFO - server - Listening on endpoint
>> tcp:port=8000:interface=127.0.0.1
>> [2018/02/03 03:14:32] WebSocket HANDSHAKING /sessions/ [127.0.0.1:8631]
>> ERROR:root:Exception inside application: 'NoneType' object has no
>> attribute 'group_add'
>>   File "c:\python35\Lib\asyncio\tasks.py", line 241, in _step
>> result = coro.throw(exc)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\consumer.py",
>> line 53, in __call__
>> await await_many_dispatch([receive], self.dispatch)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\utils.py",
>> line 48, in await_many_dispatch
>> await dispatch(result)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
>> line 84, in inner
>> return await async_func(*args, **kwargs)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
>> line 67, in __call__
>> return await asyncio.wait_for(future, timeout=None)
>>   File "c:\python35\Lib\asyncio\tasks.py", line 367, in wait_for
>> return (yield from fut)
>>   File "c:\python35\Lib\asyncio\futures.py", line 358, in __iter__
>> yield self  # This tells Task to wait for completion.
>>   File "c:\python35\Lib\asyncio\tasks.py", line 290, in _wakeup
>> future.result()
>>   File "c:\python35\Lib\asyncio\futures.py", line 274, in result
>> raise self._exception
>>   File "c:\python35\Lib\concurrent\futures\thread.py", line 55, in run
>> result = self.fn(*self.args, **self.kwargs)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
>> line 76, in thread_handler
>> raise e
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py",
>> line 74, in thread_handler
>> self.func(*args, **kwargs)
>>   File 
>> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\consumer.py",
>> line 93, in dispatch
>> handler(message)
>>   File "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\
>> channels\generic\websocket.py", line 19, in websocket_connect
>> self.connect()
>>   File "D:\Programming\DjangoWebsite\HUWebsite\husite\
>> djangoChannels\djangoChannels\consumers.py", line 8, in connect
>> AsyncToSync(self.channel_layer.group_add)("chat", self.channel_name)
>>   'NoneType' object has no attribute 'group_add'
>> [2018/02/03 03:14:32] WebSocket DISCONNECT /sessions/ [127.0.0.1:8631]
>>
>
>
> On Friday, February 2, 2018 at 7:37:36 PM UTC+2, Andrew Godwin wrote:
>>
>> Hi Ahmed,
>>
>> In the new release channel layers are optional - if you don't configure
>> them they will indeed come through as None. The settings format changed
>> slightly too - you can read more here: http://channels.readthed
>> ocs.io/en/latest/topics/channel_layers.html
>>
>> Andrew
>>
>> On Fri, Feb 2, 2018 at 3:31 AM, Ahmed Magdy  wrote:
>>
>>> I'm relatively new to channels and was using Channels v1.x.x groups
>>> easily, but after v2.0.0 update and reading the documentation
>>>
>>> # This example uses WebSocket consumer, which is synchronous, and so
>>> # needs the async channel layer functions to be converted.
>>> from asgiref.sync import AsyncToSync
>>>
>>> class ChatConsumer(WebsocketConsumer):
>>>
>>> def connect(self):
>>> 

Re: Django Channels 2.0.0 groups

2018-02-02 Thread Ahmed Magdy
That's what I did after reading the documentation here's how my channels 
files look like

# settings.py
# ...
ASGI_APPLICATION = 'djangoChannels.routing.application'
# ...

# routing.py
from django.conf.urls import url

from channels.routing import ProtocolTypeRouter, URLRouter
from channels.auth import AuthMiddlewareStack

from .consumers import ChatConsumer

application = ProtocolTypeRouter({
   # Empty for now (http->django views is added by default)
   'websocket': AuthMiddlewareStack(
   URLRouter([
   url('^sessions/$', ChatConsumer)
   ])
   )
})

# consumers.py
from asgiref.sync import AsyncToSync
from channels.generic.websocket import WebsocketConsumer

class ChatConsumer(WebsocketConsumer):

def connect(self):
   AsyncToSync(self.channel_layer.group_add)("chat", self.channel_name)

def disconnect(self):
   AsyncToSync(self.channel_layer.group_discard)("chat", self
.channel_name)


After connecting with JS websocket to 

ws://127.0.0.1:8000/sessions/
>

Raises an exception

Performing system checks...
>
> System check identified no issues (0 silenced).
> February 03, 2018 - 03:14:29
> Django version 2.0.2, using settings 'djangoChannels.settings'
> Starting ASGI/Channels development server at http://127.0.0.1:8000/
> Quit the server with CTRL-BREAK.
> 2018-02-03 03:14:29,799 - INFO - server - HTTP/2 support not enabled 
> (install the http2 and tls Twisted extras)
> 2018-02-03 03:14:29,800 - INFO - server - Listening on endpoint 
> tcp:port=8000:interface=127.0.0.1
> [2018/02/03 03:14:32] WebSocket HANDSHAKING /sessions/ [127.0.0.1:8631]
> ERROR:root:Exception inside application: 'NoneType' object has no 
> attribute 'group_add'
>   File "c:\python35\Lib\asyncio\tasks.py", line 241, in _step
> result = coro.throw(exc)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\consumer.py",
>  
> line 53, in __call__
> await await_many_dispatch([receive], self.dispatch)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\utils.py", 
> line 48, in await_many_dispatch
> await dispatch(result)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py", 
> line 84, in inner
> return await async_func(*args, **kwargs)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py", 
> line 67, in __call__
> return await asyncio.wait_for(future, timeout=None)
>   File "c:\python35\Lib\asyncio\tasks.py", line 367, in wait_for
> return (yield from fut)
>   File "c:\python35\Lib\asyncio\futures.py", line 358, in __iter__
> yield self  # This tells Task to wait for completion.
>   File "c:\python35\Lib\asyncio\tasks.py", line 290, in _wakeup
> future.result()
>   File "c:\python35\Lib\asyncio\futures.py", line 274, in result
> raise self._exception
>   File "c:\python35\Lib\concurrent\futures\thread.py", line 55, in run
> result = self.fn(*self.args, **self.kwargs)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py", 
> line 76, in thread_handler
> raise e
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\asgiref\sync.py", 
> line 74, in thread_handler
> self.func(*args, **kwargs)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\consumer.py",
>  
> line 93, in dispatch
> handler(message)
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\lib\site-packages\channels\generic\websocket.py",
>  
> line 19, in websocket_connect
> self.connect()
>   File 
> "D:\Programming\DjangoWebsite\HUWebsite\husite\djangoChannels\djangoChannels\consumers.py",
>  
> line 8, in connect
> AsyncToSync(self.channel_layer.group_add)("chat", self.channel_name)
>   'NoneType' object has no attribute 'group_add'
> [2018/02/03 03:14:32] WebSocket DISCONNECT /sessions/ [127.0.0.1:8631]
>


On Friday, February 2, 2018 at 7:37:36 PM UTC+2, Andrew Godwin wrote:
>
> Hi Ahmed,
>
> In the new release channel layers are optional - if you don't configure 
> them they will indeed come through as None. The settings format changed 
> slightly too - you can read more here: 
> http://channels.readthedocs.io/en/latest/topics/channel_layers.html
>
> Andrew
>
> On Fri, Feb 2, 2018 at 3:31 AM, Ahmed Magdy  > wrote:
>
>> I'm relatively new to channels and was using Channels v1.x.x groups 
>> easily, but after v2.0.0 update and reading the documentation
>>
>> # This example uses WebSocket consumer, which is synchronous, and so
>> # needs the async channel layer functions to be converted.
>> from asgiref.sync import AsyncToSync
>>
>> class ChatConsumer(WebsocketConsumer):
>>
>> def connect(self):
>> AsyncToSync(self.channel_layer.group_add)("chat", self.channel_name)
>>
>> def disconnect(self):
>> AsyncToSync(self.channel_layer.group_discard)("chat", 
>> self.channel_name)
>>
>> Enter code here...
>>
>> channel_layer, channel_name are always NoneType and exceptio

Re: In the Admin, Is it possible to make filters on foreign keys usable with lots of related objects?

2018-02-02 Thread Paul Tiplady
I've used that in a few admin pages, as far a I understand it just
restricts the allowed values for a model's foreignkey field when editing a
model instance. I don't see any way to use that to change how the
`list_filter` functions -- am I missing something?

Thanks,
Paul

On Fri, Feb 2, 2018 at 3:57 PM, Mike Dewhirst  wrote:

> On 3/02/2018 5:23 AM, Paul Tiplady wrote:
>
>> Currently it's simple to configure a filter on a foreign key in the admin:
>>
>> `list_filter = ['theforeignkeyfield']`
>>
>> However in practice this is barely usable in most cases that I've
>> encountered, since the admin uses RelatedFieldListFilter, which fetches the
>> full list of objects from the DB and loads them into the browser. For any
>> production site that either times out or makes the admin unusably slow, not
>> to mention the UX is terrible as it inserts a list of all of the items into
>> the filter bar that needs to be scrolled through.
>>
>> I'm not sure if this is fixed in 2.0 (I haven't played with the new
>> select2 integration that was added), but is there a plugin / workaround to
>> use something like django-autocomplete-light, or a `raw_id_field` type
>> approach in pre-2.0?
>>
>
> Have you looked at  ...
>
> https://docs.djangoproject.com/en/1.11/ref/contrib/admin/#
> django.contrib.admin.ModelAdmin.formfield_for_foreignkey
>
> M
>
>
> --
>> 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 > 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/ms
>> gid/django-users/4e610074-ff8c-494d-977e-cf701c8cd92f%40googlegroups.com
>> > c-494d-977e-cf701c8cd92f%40googlegroups.com?utm_medium=email
>> &utm_source=footer>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/to
> pic/django-users/j2pDXmEGvJE/unsubscribe.
> To unsubscribe from this group and all its topics, 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/ms
> gid/django-users/89fd33b4-c8fb-09ac-1f0b-296f82463f55%40dewhirst.com.au.
>
> 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/CAA%2BchP8RGR8HtC61bSAftMcexhQigLZsxy-tVd3T5jmz8P_HQg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: In the Admin, Is it possible to make filters on foreign keys usable with lots of related objects?

2018-02-02 Thread Mike Dewhirst

On 3/02/2018 5:23 AM, Paul Tiplady wrote:
Currently it's simple to configure a filter on a foreign key in the 
admin:


`list_filter = ['theforeignkeyfield']`

However in practice this is barely usable in most cases that I've 
encountered, since the admin uses RelatedFieldListFilter, which 
fetches the full list of objects from the DB and loads them into the 
browser. For any production site that either times out or makes the 
admin unusably slow, not to mention the UX is terrible as it inserts a 
list of all of the items into the filter bar that needs to be scrolled 
through.


I'm not sure if this is fixed in 2.0 (I haven't played with the new 
select2 integration that was added), but is there a plugin / 
workaround to use something like django-autocomplete-light, or a 
`raw_id_field` type approach in pre-2.0?


Have you looked at  ...

https://docs.djangoproject.com/en/1.11/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_for_foreignkey

M



--
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/4e610074-ff8c-494d-977e-cf701c8cd92f%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/89fd33b4-c8fb-09ac-1f0b-296f82463f55%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: In the Admin, Is it possible to make filters on foreign keys usable with lots of related objects?

2018-02-02 Thread Paul Tiplady
That's a pretty inflexible solution though; what if I want to filter on
multiple foreign keys, e.g. Tenant=Foo(id=1), Customer=Bar(id=200)?

On Fri, Feb 2, 2018 at 12:57 PM, Andy  wrote:

> You should rather use search_fields instead of filtering together with the
> sorting ability of the admin. Thats much more suited for a scenario like
> described above.
> The filter is for status fields or something with just a few different
> entries, otherwise build your own filter to filter for some specific values.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/django-users/j2pDXmEGvJE/unsubscribe.
> To unsubscribe from this group and all its topics, 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/1ffa9984-7775-49d1-bc78-6dd2de7fcf5d%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/CAA%2BchP-6LhZhu3g13Zv4g%3D9qOywB8E9HhVJPnA-%3DTe0jB1JpNQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


App 'polls' could not be found. Is it in INSTALLED_APPS?

2018-02-02 Thread Peter Mkwawa
I am having trouble in the makemigrations part

-- 
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/5f1f9803-910d-45dc-b273-76b962855a3d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: In the Admin, Is it possible to make filters on foreign keys usable with lots of related objects?

2018-02-02 Thread Andy
You should rather use search_fields instead of filtering together with the 
sorting ability of the admin. Thats much more suited for a scenario like 
described above.
The filter is for status fields or something with just a few different 
entries, otherwise build your own filter to filter for some specific values.

-- 
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/1ffa9984-7775-49d1-bc78-6dd2de7fcf5d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-02 Thread Furbee
There are a couple options you could try to see which is the best fit for
your data. With DEBUG=True in settings.py you can check the actual queries
and process time. It depends on the sizes of A and B. Another query you can
run is:

A.objects.exclude(id__in=B.objects.all().values_list('a_id', flat=True))

When I tried, it seemed to be about the same speed with my test data as the
one you had A.objects.filter(bs__isnull=True).

To see what queries are generated and the query time with DEBUG=True:
Open your Django Python Shell
>>> A.objects.exclude(id__in=B.objects.all().values_list('a_id', flat=True))
>>> A.objects.filter(bs__isnull=True)
>>> from django.db import connection
>>> for q in connection.queries:
>>> print("{0}: {1}".format(q['sql'], q['time']))

This will show you both queries generated and how long it took to get a
response from your DB.

You can also write raw SQL, if you can make one more efficiently.

Furbee

On Fri, Feb 2, 2018 at 10:56 AM, Vijay Khemlani  wrote:

> "with large of records in A and B, the above takes lot of time"
>
> How long? At first glance it doesn't look like a complex query or
> something particularly inefficient for a DB.
>
> On Fri, Feb 2, 2018 at 11:31 AM, Andy  wrote:
>
>> not that i know of
>>
>>
>> Am Freitag, 2. Februar 2018 15:28:26 UTC+1 schrieb Web Architect:
>>>
>>> Hi Andy,
>>>
>>> Thanks for your response. I was pondering on option a before posting
>>> this query thinking there could be better ways in django/SQL to handle
>>> this. But now I would probably go with a.
>>>
>>> Thanks.
>>>
>>> On Friday, February 2, 2018 at 7:50:53 PM UTC+5:30, Andy wrote:

 a) Maybe its an option to put the foreign key to the other model? This
 way you dont need to make a join to find out if there is a relation.

 b) Save the existing ralation status to model A

 c) cache the A.objects.filter(bs__isnull=False) query

 But apart from that i fear you cannot do much more, since this is just
 a DB and not a Django ORM question.


 Am Freitag, 2. Februar 2018 14:47:45 UTC+1 schrieb Web Architect:
>
> Hi,
>
> I am trying to optimise Django queries on my ecommerce website. One of
> the fundamental query is where I have no clue how to make efficient. It
> could be trivial and probably been known long time back. But I am new to
> Django and would appreciate any help. This is primarily for one to many or
> many to many relations.
>
> Following is an example scenario:
> (Please pardon my syntax as I want to put across the concept and not
> the exact django code unless it's really needed):
>
> Model A:
>
> class A(models.Model):
> # Fields of model A
>
> Model B (which is related to A with foreign key):
>
> class B(models.Model):
> a = models.ForeignKey('A', related_name='bs')
>
> Now I would like to find out all As for which there is atleast one b.
> The only way I know is as follows:
>
> A.objects.filter(bs__isnull=False)
>
> But the above isn't an optimal way as with large of records in A and
> B, the above takes lot of time. It gets more inefficient if it's a many to
> many relationship.
>
> Could anyone please let me know the most efficient way to use django
> queryset for the above scenario?
>
> Thanks.
>
 --
>> 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/ms
>> gid/django-users/73ed5ff7-d4db-4057-a812-01c82bf08cf3%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/CALn3ei1Q2p31NrcdYC-2EPfH78kBxCXZPZKW1e6k%
> 2BqCTuUgYDw%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 
"

Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-02 Thread Vijay Khemlani
"with large of records in A and B, the above takes lot of time"

How long? At first glance it doesn't look like a complex query or something
particularly inefficient for a DB.

On Fri, Feb 2, 2018 at 11:31 AM, Andy  wrote:

> not that i know of
>
>
> Am Freitag, 2. Februar 2018 15:28:26 UTC+1 schrieb Web Architect:
>>
>> Hi Andy,
>>
>> Thanks for your response. I was pondering on option a before posting this
>> query thinking there could be better ways in django/SQL to handle this. But
>> now I would probably go with a.
>>
>> Thanks.
>>
>> On Friday, February 2, 2018 at 7:50:53 PM UTC+5:30, Andy wrote:
>>>
>>> a) Maybe its an option to put the foreign key to the other model? This
>>> way you dont need to make a join to find out if there is a relation.
>>>
>>> b) Save the existing ralation status to model A
>>>
>>> c) cache the A.objects.filter(bs__isnull=False) query
>>>
>>> But apart from that i fear you cannot do much more, since this is just a
>>> DB and not a Django ORM question.
>>>
>>>
>>> Am Freitag, 2. Februar 2018 14:47:45 UTC+1 schrieb Web Architect:

 Hi,

 I am trying to optimise Django queries on my ecommerce website. One of
 the fundamental query is where I have no clue how to make efficient. It
 could be trivial and probably been known long time back. But I am new to
 Django and would appreciate any help. This is primarily for one to many or
 many to many relations.

 Following is an example scenario:
 (Please pardon my syntax as I want to put across the concept and not
 the exact django code unless it's really needed):

 Model A:

 class A(models.Model):
 # Fields of model A

 Model B (which is related to A with foreign key):

 class B(models.Model):
 a = models.ForeignKey('A', related_name='bs')

 Now I would like to find out all As for which there is atleast one b.
 The only way I know is as follows:

 A.objects.filter(bs__isnull=False)

 But the above isn't an optimal way as with large of records in A and B,
 the above takes lot of time. It gets more inefficient if it's a many to
 many relationship.

 Could anyone please let me know the most efficient way to use django
 queryset for the above scenario?

 Thanks.

>>> --
> 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/73ed5ff7-d4db-4057-a812-01c82bf08cf3%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/CALn3ei1Q2p31NrcdYC-2EPfH78kBxCXZPZKW1e6k%2BqCTuUgYDw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Newbie - Microservice in Django - Best place to start learning

2018-02-02 Thread Paul Tiplady
Assuming you're trying to build a REST API and not a HTML website, you 
should look at http://www.django-rest-framework.org/ as it provides a lot 
of djangonic convenience methods for building REST APIs with the Django ORM.

On Thursday, February 1, 2018 at 9:16:47 AM UTC-8, pratibha sharma wrote:
>
> Hi,
>
> I have created 2 example websites in Django i.e. Voting and event booking 
> systems. 
> I want to learn to create microservice in Django. I took below example for 
> it.
>
> Service will 
> 1. take data from UI (it will send it in JSON format), 
> 2. store data in DB(MySQL)
> 3. Send Data to a device (in JSON format)
>
> My mind is flooded with questions like 
> how UI and service with communicate? 
> how can service communicate to device? etc.
>
> I am not sure where should I start and how to create the design for this 
> work. I am new in microservice and some experience in django.
>
> Please guide me.
>

-- 
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/ee24fd34-b612-4d79-8980-c79fbd4e54bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


In the Admin, Is it possible to make filters on foreign keys usable with lots of related objects?

2018-02-02 Thread Paul Tiplady
Currently it's simple to configure a filter on a foreign key in the admin:

`list_filter = ['theforeignkeyfield']`

However in practice this is barely usable in most cases that I've 
encountered, since the admin uses RelatedFieldListFilter, which fetches the 
full list of objects from the DB and loads them into the browser. For any 
production site that either times out or makes the admin unusably slow, not 
to mention the UX is terrible as it inserts a list of all of the items into 
the filter bar that needs to be scrolled through.

I'm not sure if this is fixed in 2.0 (I haven't played with the new select2 
integration that was added), but is there a plugin / workaround to use 
something like django-autocomplete-light, or a `raw_id_field` type approach 
in pre-2.0?

-- 
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/4e610074-ff8c-494d-977e-cf701c8cd92f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Channels 2.0.0 groups

2018-02-02 Thread Andrew Godwin
Hi Ahmed,

In the new release channel layers are optional - if you don't configure
them they will indeed come through as None. The settings format changed
slightly too - you can read more here:
http://channels.readthedocs.io/en/latest/topics/channel_layers.html

Andrew

On Fri, Feb 2, 2018 at 3:31 AM, Ahmed Magdy  wrote:

> I'm relatively new to channels and was using Channels v1.x.x groups
> easily, but after v2.0.0 update and reading the documentation
>
> # This example uses WebSocket consumer, which is synchronous, and so
> # needs the async channel layer functions to be converted.
> from asgiref.sync import AsyncToSync
>
> class ChatConsumer(WebsocketConsumer):
>
> def connect(self):
> AsyncToSync(self.channel_layer.group_add)("chat", self.channel_name)
>
> def disconnect(self):
> AsyncToSync(self.channel_layer.group_discard)("chat", 
> self.channel_name)
>
> Enter code here...
>
> channel_layer, channel_name are always NoneType and exception occurs.
>
> Is that because I didn't configure channel layers? But in the old version
> I also used the in memory type and Groups were working well.
>
> --
> 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/fff84d59-da69-47d5-a7c3-ee0221680642%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/CAFwN1uqxVR%2BU%3DJFnOnmuBW7CR23A626uqiGuR98%2B9%3DYUi%3DWVCA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-02 Thread Andy
not that i know of

Am Freitag, 2. Februar 2018 15:28:26 UTC+1 schrieb Web Architect:
>
> Hi Andy,
>
> Thanks for your response. I was pondering on option a before posting this 
> query thinking there could be better ways in django/SQL to handle this. But 
> now I would probably go with a.
>
> Thanks.
>
> On Friday, February 2, 2018 at 7:50:53 PM UTC+5:30, Andy wrote:
>>
>> a) Maybe its an option to put the foreign key to the other model? This 
>> way you dont need to make a join to find out if there is a relation.
>>
>> b) Save the existing ralation status to model A
>>
>> c) cache the A.objects.filter(bs__isnull=False) query
>>
>> But apart from that i fear you cannot do much more, since this is just a 
>> DB and not a Django ORM question.
>>
>>
>> Am Freitag, 2. Februar 2018 14:47:45 UTC+1 schrieb Web Architect:
>>>
>>> Hi,
>>>
>>> I am trying to optimise Django queries on my ecommerce website. One of 
>>> the fundamental query is where I have no clue how to make efficient. It 
>>> could be trivial and probably been known long time back. But I am new to 
>>> Django and would appreciate any help. This is primarily for one to many or 
>>> many to many relations.
>>>
>>> Following is an example scenario:
>>> (Please pardon my syntax as I want to put across the concept and not the 
>>> exact django code unless it's really needed):
>>>
>>> Model A:
>>>
>>> class A(models.Model):
>>> # Fields of model A
>>>
>>> Model B (which is related to A with foreign key):
>>>
>>> class B(models.Model):
>>> a = models.ForeignKey('A', related_name='bs')
>>>
>>> Now I would like to find out all As for which there is atleast one b. 
>>> The only way I know is as follows:
>>>
>>> A.objects.filter(bs__isnull=False)
>>>
>>> But the above isn't an optimal way as with large of records in A and B, 
>>> the above takes lot of time. It gets more inefficient if it's a many to 
>>> many relationship.
>>>
>>> Could anyone please let me know the most efficient way to use django 
>>> queryset for the above scenario?
>>>
>>> Thanks.
>>>
>>

-- 
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/73ed5ff7-d4db-4057-a812-01c82bf08cf3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-02 Thread Web Architect
Hi Andy,

Thanks for your response. I was pondering on option a before posting this 
query thinking there could be better ways in django/SQL to handle this. But 
now I would probably go with a.

Thanks.

On Friday, February 2, 2018 at 7:50:53 PM UTC+5:30, Andy wrote:
>
> a) Maybe its an option to put the foreign key to the other model? This way 
> you dont need to make a join to find out if there is a relation.
>
> b) Save the existing ralation status to model A
>
> c) cache the A.objects.filter(bs__isnull=False) query
>
> But apart from that i fear you cannot do much more, since this is just a 
> DB and not a Django ORM question.
>
>
> Am Freitag, 2. Februar 2018 14:47:45 UTC+1 schrieb Web Architect:
>>
>> Hi,
>>
>> I am trying to optimise Django queries on my ecommerce website. One of 
>> the fundamental query is where I have no clue how to make efficient. It 
>> could be trivial and probably been known long time back. But I am new to 
>> Django and would appreciate any help. This is primarily for one to many or 
>> many to many relations.
>>
>> Following is an example scenario:
>> (Please pardon my syntax as I want to put across the concept and not the 
>> exact django code unless it's really needed):
>>
>> Model A:
>>
>> class A(models.Model):
>> # Fields of model A
>>
>> Model B (which is related to A with foreign key):
>>
>> class B(models.Model):
>> a = models.ForeignKey('A', related_name='bs')
>>
>> Now I would like to find out all As for which there is atleast one b. The 
>> only way I know is as follows:
>>
>> A.objects.filter(bs__isnull=False)
>>
>> But the above isn't an optimal way as with large of records in A and B, 
>> the above takes lot of time. It gets more inefficient if it's a many to 
>> many relationship.
>>
>> Could anyone please let me know the most efficient way to use django 
>> queryset for the above scenario?
>>
>> Thanks.
>>
>

-- 
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/a7522736-166e-4d6d-8b8a-a6f88b0d6f47%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-02 Thread Andy
a) Maybe its an option to put the foreign key to the other model? This way 
you dont need to make a join to find out if there is a relation.

b) Save the existing ralation status to model A

c) cache the A.objects.filter(bs__isnull=False) query

But apart from that i fear you cannot do much more, since this is just a DB 
and not a Django ORM question.


Am Freitag, 2. Februar 2018 14:47:45 UTC+1 schrieb Web Architect:
>
> Hi,
>
> I am trying to optimise Django queries on my ecommerce website. One of the 
> fundamental query is where I have no clue how to make efficient. It could 
> be trivial and probably been known long time back. But I am new to Django 
> and would appreciate any help. This is primarily for one to many or many to 
> many relations.
>
> Following is an example scenario:
> (Please pardon my syntax as I want to put across the concept and not the 
> exact django code unless it's really needed):
>
> Model A:
>
> class A(models.Model):
> # Fields of model A
>
> Model B (which is related to A with foreign key):
>
> class B(models.Model):
> a = models.ForeignKey('A', related_name='bs')
>
> Now I would like to find out all As for which there is atleast one b. The 
> only way I know is as follows:
>
> A.objects.filter(bs__isnull=False)
>
> But the above isn't an optimal way as with large of records in A and B, 
> the above takes lot of time. It gets more inefficient if it's a many to 
> many relationship.
>
> Could anyone please let me know the most efficient way to use django 
> queryset for the above scenario?
>
> Thanks.
>

-- 
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/d5fb0d86-aff8-4c97-a6d7-1d04ddf3d466%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Optimal query for related names in onetomany or manytomany using Django Queryset

2018-02-02 Thread Web Architect
Hi,

I am trying to optimise Django queries on my ecommerce website. One of the 
fundamental query is where I have no clue how to make efficient. It could 
be trivial and probably been known long time back. But I am new to Django 
and would appreciate any help. This is primarily for one to many or many to 
many relations.

Following is an example scenario:
(Please pardon my syntax as I want to put across the concept and not the 
exact django code unless it's really needed):

Model A:

class A(models.Model):
# Fields of model A

Model B (which is related to A with foreign key):

class B(models.Model):
a = models.ForeignKey('A', related_name='bs')

Now I would like to find out all As for which there is atleast one b. The 
only way I know is as follows:

A.objects.filter(bs__isnull=False)

But the above isn't an optimal way as with large of records in A and B, the 
above takes lot of time. It gets more inefficient if it's a many to many 
relationship.

Could anyone please let me know the most efficient way to use django 
queryset for the above scenario?

Thanks.

-- 
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/4817c6c7-987b-4b71-aef3-3ed910e1be5e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Channels 2.0.0 groups

2018-02-02 Thread Ahmed Magdy
I'm relatively new to channels and was using Channels v1.x.x groups easily, 
but after v2.0.0 update and reading the documentation

# This example uses WebSocket consumer, which is synchronous, and so
# needs the async channel layer functions to be converted.
from asgiref.sync import AsyncToSync

class ChatConsumer(WebsocketConsumer):

def connect(self):
AsyncToSync(self.channel_layer.group_add)("chat", self.channel_name)

def disconnect(self):
AsyncToSync(self.channel_layer.group_discard)("chat", self.channel_name)

Enter code here...

channel_layer, channel_name are always NoneType and exception occurs.

Is that because I didn't configure channel layers? But in the old version I 
also used the in memory type and Groups were working well.

-- 
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/fff84d59-da69-47d5-a7c3-ee0221680642%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Customizable Invoice

2018-02-02 Thread Andy
Well since your answer is no, you should take you time and learn 
Python/Dajngo before asking anyone in here to basically write that invoice 
app for you. :)

Basically Django can do what you are asking for, but i'd recommend you to 
use it only as a backend for this highly UI focused problem. Then think 
about what the frontend will be (web, app, mobile) and choose something 
that has the needed frontend components that you would like to use. 

But let me tell you this: a totally customizable invoice with that shall 
still look pretty and can be printed out in any combination of item rows 
and extra details is probably one of the hardest tasks you can think of not 
having any programming background!
Having kinda done the above i can definitely recommend the 
awesome https://github.com/Kozea/WeasyPrint library for generating PDF 
files!

But it sounds to me that you should do yourself a favour and read this 
before actually starting your 
project: https://www.twoscoopspress.com/products/two-scoops-of-django-1-11

Have fun!

 

Am Freitag, 2. Februar 2018 10:24:31 UTC+1 schrieb Rakhee Menon:
>
>
>
> No...I wanted to know if i could do it using django and if yes...how to do 
> it??
>

-- 
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/a023e7d3-8a28-40cd-917b-ae9c8673dc7a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Customizable Invoice

2018-02-02 Thread Jani Tiainen

Hi,

This actually isn't much of doing with Django. It's more just about your 
UI to be able to do things you want to.


Django definitely can record your invoice format and you can even print 
it out in a format stored in Django.


But what you need is tool for UI (in browser) which allows you do all 
the arranging and such.


On 2.2.2018 11.23, Rakhee Menon wrote:


Hi,
I am going to use django.

Regards,
Rakhee
--
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/158c19f4-0596-4994-b9c2-0d9388c16566%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
Jani Tiainen

--
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/471da3b7-a606-8ef7-f198-bea2e65b52fb%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Customizable Invoice

2018-02-02 Thread Rakhee Menon


No...I wanted to know if i could do it using django and if yes...how to do 
it??

-- 
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/002a9e3b-c9a5-4a3b-919b-fc28619ea10a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Customizable Invoice

2018-02-02 Thread Rakhee Menon

Hi,
I am going to use django.

Regards,
Rakhee

-- 
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/158c19f4-0596-4994-b9c2-0d9388c16566%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Customizable Invoice

2018-02-02 Thread Andy
Do you have any idea in any programming language you know how to do what 
you are asking for?

-- 
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/bbce7792-6cec-4599-b10e-238516da5106%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.