bug in bulk_create

2020-08-04 Thread nima salemahim


Traceback (most recent call last):
  File "/usr/lib/python3.7/code.py", line 90, in runcode
exec(code, self.locals)
  File "", line 1, in 
  File 
"/home/nima/.virtualenvs/behtarino/lib/python3.7/site-packages/django/db/models/fields/related_descriptors.py",
 
line 946, in add
through_defaults=through_defaults,
  File 
"/home/nima/.virtualenvs/behtarino/lib/python3.7/site-packages/django/db/models/fields/related_descriptors.py",
 
line 1150, in _add_items
])
TypeError: bulk_create() got an unexpected keyword argument 
'ignore_conflicts'

hi i have three models

when i try to add on deal to one a category 

like : deal.categories.add(category)

i face error above can you help me about what the problem is ?

i dont know exactly it is django problem or django-ordered-model module 
problem

class Deal(ModificationLogMixin, models.Model):
title = models.CharField(max_length=160, blank=True, null=True)
description = models.TextField(blank=True, null=True)
initial_price = models.IntegerField(blank=True)
discounted_price = models.IntegerField(blank=True)
categories = models.ManyToManyField(
'deal.DealCategory',
related_name='deals',
blank=True,
through='DealCategoryThrough',
through_fields=('deal', 'dealcategory')
)

class DealCategory(OrderedModel):
business = models.ForeignKey(Business, related_name='deal_categories',
 on_delete=deletion.CASCADE)
name = models.CharField(max_length=100, blank=True, null=True)
order_with_respect_to = 'business'

class DealCategoryThrough(OrderedModel):
deal = models.ForeignKey('deal.Deal', on_delete=models.deletion.CASCADE,
 related_name='ordered_deals')
dealcategory = models.ForeignKey(DealCategory, 
on_delete=models.deletion.CASCADE,
 related_name='ordered_deals')
order_with_respect_to = 'dealcategory'

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d8e04200-2f6f-4cf8-a315-30bb33ea761bo%40googlegroups.com.


bug bulk_create

2020-08-04 Thread nima salemahim


Traceback (most recent call last):
  File "/usr/lib/python3.7/code.py", line 90, in runcode
exec(code, self.locals)
  File "", line 1, in 
  File 
"/home/nima/.virtualenvs/behtarino/lib/python3.7/site-packages/django/db/models/fields/related_descriptors.py",
 
line 946, in add
through_defaults=through_defaults,
  File 
"/home/nima/.virtualenvs/behtarino/lib/python3.7/site-packages/django/db/models/fields/related_descriptors.py",
 
line 1150, in _add_items
])
TypeError: bulk_create() got an unexpected keyword argument 
'ignore_conflicts'

hi i have three models

when i try to add on deal to one a category 

like : deal.categories.add(category)

i face error above can you help me about what the problem is ?

class Deal(ModificationLogMixin, models.Model):
title = models.CharField(max_length=160, blank=True, null=True)
description = models.TextField(blank=True, null=True)
initial_price = models.IntegerField(blank=True)
discounted_price = models.IntegerField(blank=True)
categories = models.ManyToManyField(
'deal.DealCategory',
related_name='deals',
blank=True,
through='DealCategoryThrough',
through_fields=('deal', 'dealcategory')
)

class DealCategory(OrderedModel):
business = models.ForeignKey(Business, related_name='deal_categories',
 on_delete=deletion.CASCADE)
name = models.CharField(max_length=100, blank=True, null=True)
order_with_respect_to = 'business'

class DealCategoryThrough(OrderedModel):
deal = models.ForeignKey('deal.Deal', on_delete=models.deletion.CASCADE,
 related_name='ordered_deals')
dealcategory = models.ForeignKey(DealCategory, 
on_delete=models.deletion.CASCADE,
 related_name='ordered_deals')
order_with_respect_to = 'dealcategory'

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2051380a-62b9-4afc-be91-f264cdf3e38eo%40googlegroups.com.


Re: Udemy Clone

2020-08-04 Thread nima salemahim
i am backend developer of an organization and faced to this problem i have
an OrderdModel class (DealCategory) and i wanted to make my (Deal) model
also OrderdModel
so i tried this way and faced this problem while adding a deal to
dealcategory i am not share that it is django problem or django-order-model
module problem do you have any idea to help me ?

On Tue, Aug 4, 2020 at 2:15 PM Venkata Penumatsa  wrote:

> Hi Vedant,
>
> Is this a hobby project or organization project? Is there any budget for
> this project? If so how much is the budget?
>
>
> On Sun, 2 Aug 2020 at 13:45, Kasper Laudrup  wrote:
>
>> Hi Yedant,
>>
>> On 02/08/2020 17.54, vedant mehta wrote:
>> > I m facing many problems. Video player , forum for qna, creating
>> assignment page, stars for the instructor, generating certificate.
>> >
>>
>> So far we can gather that you want to do something, but have no idea how
>> to do any of it and therefore need some help.
>>
>> Nothing wrong with that, but it would greatly improve your chances of
>> getting help if you try to clarify which kind of help you are looking for.
>>
>> Do you have any programming experience at all and do you have some code
>> you are willing to share so someone can have a look at it?
>>
>> Are you looking for a mentor and would you be willing to pay someone to
>> help you learning Python/Django development?
>>
>> Do you have any specific problems that you would like anyone to help you
>> with?
>>
>> So far, no one knows but you, so you'll probably not get any relevant
>> help before you make it clear what you're looking for.
>>
>> Kind regards,
>>
>> Kasper Laudrup
>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/ff1b0da0-0b14-02ce-74fe-e564fd0f69aa%40stacktrace.dk
>> .
>>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAPROKTc6UqYbDVXs0ts6qmgEHX915sKc%3DA12yJ_OnEN0z9idaA%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHyNETR500QODsppZn9Qknb%2BcCeX4y2-2KdZ2CLFnn9PF%3D6Y0g%40mail.gmail.com.


Raise concurrent.futures._base.CancelledError when i test django channels websocket

2019-06-11 Thread nima
Hi. I'm using Django channels in server side for a speech to text 
application. When I test websocket with jmeter(+120 user or thread in 1 
second), about half of requests fail. Here is my code:

class Consumer(AsyncWebsocketConsumer):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.session = aiohttp.ClientSession()
# some other initialization

async def connect(self):
await self.accept()

async def received(self, text_data=None, bytes_data=None):
self.data = bytes_data
async with self.session:
  await self.send(bytes_data=(await 
self._fetch(self.session)).encode())

async def _fetch(self, client):
async with client.post(url=self.url,
  headers=self.headers,
  
params=self.querystrings,
  data=self.data) as 
resp:
return await resp.text()



for 100-120 requests in 1 sec(i.e. 100-120 users in jmeter) it works well. 
But for +120 requests some of them failed. Each request sends 319523 bytes 
to websocket and then websocket sends them to an api and send back 
response. Here is the exception that raise for +120 requests:



[2019-06-11 07:20:29 +] [31064] [ERROR] Exception in ASGI application

Traceback (most recent call last):

File "/usr/lib/python3.5/asyncio/tasks.py", line 241, in _step

result = coro.throw(exc)

File "/usr/local/lib/python3.5/dist-packages/websockets/protocol.py", line 
674, in transfer_data

message = yield from self.read_message()

File "/usr/local/lib/python3.5/dist-packages/websockets/protocol.py", line 
742, in read_message

frame = yield from self.read_data_frame(max_size=self.max_size)

File "/usr/local/lib/python3.5/dist-packages/websockets/protocol.py", line 
815, in read_data_frame

frame = yield from self.read_frame(max_size)

File "/usr/local/lib/python3.5/dist-packages/websockets/protocol.py", line 
884, in read_frame

extensions=self.extensions,

File "/usr/local/lib/python3.5/dist-packages/websockets/framing.py", line 
99, in read

data = yield from reader(2)

File "/usr/lib/python3.5/asyncio/streams.py", line 669, in readexactly

yield from self._wait_for_data('readexactly')

File "/usr/lib/python3.5/asyncio/streams.py", line 459, in _wait_for_data

yield from self._waiter

File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__

yield self # This tells Task to wait for completion.

File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup

future.result()

File "/usr/lib/python3.5/asyncio/futures.py", line 285, in result

raise CancelledError

concurrent.futures._base.CancelledError


The above exception was the direct cause of the following exception:


Traceback (most recent call last):

File 
"/usr/local/lib/python3.5/dist-packages/uvicorn/protocols/websockets/websockets_impl.py",
 
line 146, in run_asgi

result = await self.app(self.scope, self.asgi_receive, self.asgi_send)

File "/usr/local/lib/python3.5/dist-packages/uvicorn/middleware/asgi2.py", 
line 7, in __call__

await instance(receive, send)

File "/usr/local/lib/python3.5/dist-packages/channels/sessions.py", line 
183, in __call__

return await self.inner(receive, self.send)

File "/usr/local/lib/python3.5/dist-packages/channels/middleware.py", line 
41, in coroutine_call

await inner_instance(receive, send)

File "/usr/local/lib/python3.5/dist-packages/channels/consumer.py", line 
59, in __call__

[receive, self.channel_receive], self.dispatch

File "/usr/local/lib/python3.5/dist-packages/channels/utils.py", line 52, 
in await_many_dispatch

await dispatch(result)

File "/usr/local/lib/python3.5/dist-packages/channels/consumer.py", line 
73, in dispatch

await handler(message)

File 
"/usr/local/lib/python3.5/dist-packages/channels/generic/websocket.py", 
line 198, in websocket_receive

await self.receive(bytes_data=message["bytes"])

File "/home/nima/stt/stt_project/stt_app/consumer.py", line 257, in receive

await self.send(bytes_data=(await self._fetch(self.session)).encode())

File 
"/usr/local/lib/python3.5/dist-packages/channels/generic/websocket.py", 
line 213, in send

await super().send({"type": "websocket.send", "bytes": bytes_data})

File "/usr/local/lib/python3.5/dist-packages/channels/consumer.py", line 
81, in send

await self.base_send(message)

File "/usr/local/lib/python3.5/dist-packages/channels/sessions.py", line 
236, in send

return await self.real_send(message)

File 
"/usr/local/lib/python3.5/dist-packages/uvicorn/protocols/w

how to make a datatime filed model without timestamp?

2011-02-05 Thread Nima Gaemi
hello,
i am using Djano 1.3 rev.15387 and i made a field
'last_updated=models.DateTimeField(auto_now=True)'
when i wanted to get the data out of the database i wanted to get a
delta with datetime module of python but i was warned that my
datetime.datetime.now() object was not timezone aware.so i though
about turning off timezone in postgres too.with pgadmin i was able to
turn it off and my results was ok.but i don't know if i can do similar
at the time of model creation in django model.is that possible? [sth
like  last_updated=models.DateTimeField(timestamp_timezoneaware=False)]

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.